Skip to content

run on all paths

run on all paths #1

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:
prepare-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 "::set-output name=github_user::${{github.event.pull_request.head.repo.owner.login}}"
else
echo "::set-output name=github_user::$(echo ${{github.repository}} | cut -d'/' -f1)"
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 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/rootzoll/raspiblitz/actions/workflows/amd64-lean-image.yml/runs?branch=dev&status=success" \
| jq -r '.workflow_runs[0].id')
echo "::set-output name=run_id::$RUN_ID"
- name: Get Artifact Download URL
id: get-artifact-url
run: |
ARTIFACT_URL=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/rootzoll/raspiblitz/actions/runs/${{ steps.get-run-id.outputs.run_id }}/artifacts" \
| jq -r '.artifacts[0].archive_download_url')
echo "::set-output name=url::$ARTIFACT_URL"
- name: Download Artifact
run: |
curl -L -o artifact.zip -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ steps.get-artifact-url.outputs.url }}
- name: Decompress Image
run: |
gzip -d raspiblitz-amd64-debian-lean.qcow2.gz
- name: Extract Checksum
id: checksum
run: |
CHECKSUM=$(cat raspiblitz-amd64-debian-lean.qcow2.sha256 | awk '{print $1}')
echo "::set-output name=value::$CHECKSUM"
- name: Run the build script
run: |
echo "Using the variables: --image_link ${{github.workspace}}/raspiblitz-amd64-debian-lean.qcow2 --image_checksum ${{steps.checksum.outputs.value}} --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.build.amd64-debian.sh --image_link ${{github.workspace}}/raspiblitz-amd64-debian-lean.qcow2 --image_checksum ${{steps.checksum.outputs.value}} --github_user ${{steps.set_values.outputs.github_user}} --branch ${{env.BRANCH_NAME}} --github_user ${{steps.set_values.outputs.github_user}} --branch ${{env.BRANCH_NAME}}