Skip to content

test ci run

test ci run #11

name: test-amd64-image
concurrency:
group: amd64-lean-image-build-${{ github.head_ref }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches: ["dev", "v1.10", "test-ci"]
#paths:
# - "home.admin/cl.install.sh"
pull_request:
branches: ["dev", "v1.10", "test-ci"]
#paths:
# - "home.admin/cl.install.sh"
jobs:
test-amd64-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set values
id: set_values
run: |
echo "BUILD_DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
echo "BUILD_VERSION=$(git describe --always --tags)" >> $GITHUB_ENV
if [ -z "$GITHUB_HEAD_REF" ]; then
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
else
echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
fi
if [[ "${{github.event_name}}" == "pull_request" ]]; then
echo "GITHUB_USER=${{github.event.pull_request.head.repo.owner.login}}" >> $GITHUB_OUTPUT
else
echo "GITHUB_USER=$(echo ${{github.repository}} | cut -d'/' -f1)" >> $GITHUB_OUTPUT
fi
- name: Display values
run: |
echo "BUILD_DATE: ${{env.BUILD_DATE}}"
echo "BUILD_VERSION: ${{env.BUILD_VERSION}}"
echo "BRANCH_NAME: ${{env.BRANCH_NAME}}"
echo "GITHUB_USER: ${{steps.set_values.outputs.GITHUB_USER}}"
- name: Get the last successful workflow run ID
id: get-run-id
run: |
RUN_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/raspiblitz/raspiblitz/actions/workflows/amd64-lean-image.yml/runs?branch=dev&status=success" \
| jq -r '.workflow_runs[0].id')
echo "RUN_ID=$RUN_ID" >> $GITHUB_OUTPUT
- name: Get the artifact download URL
id: get-artifact-url
run: |
ARTIFACT_URL=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/raspiblitz/raspiblitz/actions/runs/${{ steps.get-run-id.outputs.RUN_ID }}/artifacts" \
| jq -r '.artifacts[0].archive_download_url')
echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_OUTPUT
- name: Download the artifact
run: |
curl -sS -L -o artifact.zip -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ steps.get-artifact-url.outputs.ARTIFACT_URL }}
- name: Decompress the image
run: |
unzip artifact.zip
ls -la
gzip -d raspiblitz-amd64-debian-lean.qcow2.gz
- name: Extract the checksum
id: checksum
run: |
CHECKSUM=$(cat raspiblitz-amd64-debian-lean.qcow2.sha256 | awk '{print $1}')
echo "CHECKSUM=$CHECKSUM" >> $GITHUB_OUTPUT
- name: Mount the image and run the test.raspiblitz.sh
run: |
echo "Using the variables: --image_link ${{github.workspace}}/raspiblitz-amd64-debian-lean.qcow2 --image_checksum ${{steps.checksum.outputs.CHECKSUM}} --github_user ${{steps.set_values.outputs.GITHUB_USER}} --branch ${{env.BRANCH_NAME}} --github_user ${{steps.set_values.outputs.GITHUB_USER}} --branch ${{env.BRANCH_NAME}}"
cd ci/amd64
bash packer.test.amd64-debian.sh --image_link ${{github.workspace}}/raspiblitz-amd64-debian-lean.qcow2 --image_checksum ${{steps.checksum.outputs.CHECKSUM}} --github_user ${{steps.set_values.outputs.GITHUB_USER}} --branch ${{env.BRANCH_NAME}} --github_user ${{steps.set_values.outputs.GITHUB_USER}} --branch ${{env.BRANCH_NAME}}