From acf203a94bb56944524cd9f77373b1b0ac53cdab Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Thu, 11 Jan 2024 17:58:31 +0100 Subject: [PATCH] Package handling changes. * Add DISTRO_CODENAME support. * Exit early in 'Sync changes' when no diff. --- .github/workflows/cd-libs-metadata.yml | 14 ++++++++------ .github/workflows/ci-deb-packages-v2.yml | 13 ++++++++----- .github/workflows/ci-libs-metadata-v2.yml | 12 ++++++------ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/cd-libs-metadata.yml b/.github/workflows/cd-libs-metadata.yml index 9fafa0ab..6cbc6d39 100644 --- a/.github/workflows/cd-libs-metadata.yml +++ b/.github/workflows/cd-libs-metadata.yml @@ -61,7 +61,7 @@ jobs: sync: runs-on: ${{ inputs.RUNNER }} - name: Sync metadata for ${{inputs.LIB_NAME}} at ${{inputs.FILE_PATH}}/${{inputs.ARTIFACT_NAME}} + name: Sync metadata for ${{ inputs.LIB_NAME }} at ${{ inputs.FILE_PATH }}/${{ inputs.ARTIFACT_NAME }} environment: ${{ inputs.ENVIRONMENT }} steps: @@ -71,7 +71,7 @@ jobs: id: metabranch with: repository: ${{ inputs.TARGET_REPO }} - ref: ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{inputs.TARGET_PLATFORM}} + ref: ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{ inputs.TARGET_PLATFORM }} ssh-key: ${{ secrets.GH_BOT_DEPLOY_KEY }} token: ${{ secrets.GH_BOT_DEPLOY_TOKEN || github.token }} @@ -86,8 +86,8 @@ jobs: - name: Create remote continue-on-error: true run: | - git checkout -b ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{inputs.TARGET_PLATFORM}} - git push --set-upstream origin ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{inputs.TARGET_PLATFORM}} + git checkout -b ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{ inputs.TARGET_PLATFORM }} + git push --set-upstream origin ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{ inputs.TARGET_PLATFORM }} - name: Download Artifacts uses: actions/download-artifact@v4 @@ -95,11 +95,13 @@ jobs: name: ${{ inputs.ARTIFACT_NAME }} - name: Sync changes + shell: sh run: | - git checkout ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{inputs.TARGET_PLATFORM}} + git checkout ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{ inputs.TARGET_PLATFORM }} git pull + git status --porcelain && exit 0 git add metafile.txt git config --global user.email "github-actions@github.com" git config --global user.name "github-actions" git commit -m "update metadata" - git push \ No newline at end of file + git push diff --git a/.github/workflows/ci-deb-packages-v2.yml b/.github/workflows/ci-deb-packages-v2.yml index 07c9992e..3bd01bd3 100644 --- a/.github/workflows/ci-deb-packages-v2.yml +++ b/.github/workflows/ci-deb-packages-v2.yml @@ -22,7 +22,11 @@ on: description: Default base branch to create a PR. BASE_IMAGE: required: true - description: Base image used to build + description: Base image without tag used to build + type: string + DISTRO_CODENAME: + required: true + description: Base image tag used to build type: string PLATFORM: required: false @@ -44,7 +48,7 @@ jobs: with: fetch-depth: 0 - - name: General debs based on ${{ inputs.BASE_IMAGE }} for ${{ inputs.PLATFORM }} + - name: General debs based on ${{ inputs.BASE_IMAGE }}:${{ inputs.DISTRO_CODENAME }} for ${{ inputs.PLATFORM }} shell: sh run: | mkdir -v -p /tmp/$GITHUB_RUN_ID/ @@ -86,13 +90,12 @@ jobs: uses: docker/setup-qemu-action@v3 - name: build debs - run: docker run --platform linux/${{inputs.PLATFORM}} --rm --entrypoint="/usr/local/bin/run.sh" -w /root -v $(pwd):/root -v /tmp/${GITHUB_RUN_ID}/run.sh:/usr/local/bin/run.sh ${{inputs.BASE_IMAGE}} + run: docker run --platform linux/${{ inputs.PLATFORM }} --rm --entrypoint="/usr/local/bin/run.sh" -w /root -v $(pwd):/root -v /tmp/${GITHUB_RUN_ID}/run.sh:/usr/local/bin/run.sh ${{ inputs.BASE_IMAGE }}:${{ inputs.DISTRO_CODENAME }} - name: Set custom variables shell: sh run: | - codename=$(echo ${{inputs.BASE_IMAGE}} | awk -F ':' '{print $2}') - echo "IMAGE_TAG=$codename-${{inputs.PLATFORM}}" >> $GITHUB_ENV + echo "IMAGE_TAG=${{ inputs.DISTRO_CODENAME }}-${{ inputs.PLATFORM }}" >> $GITHUB_ENV - name: Copy git hash shell: sh diff --git a/.github/workflows/ci-libs-metadata-v2.yml b/.github/workflows/ci-libs-metadata-v2.yml index 2e6e45e6..702ee9e6 100644 --- a/.github/workflows/ci-libs-metadata-v2.yml +++ b/.github/workflows/ci-libs-metadata-v2.yml @@ -15,18 +15,18 @@ on: type: string description: A GitHub runner type ARTIFACT_NAME: - required: false + required: true default: '' description: The artifact name to pull from a previous step type: string FILE_PATH_PREFIX: - required: false + required: true default: '' description: A prefix to append to meta file. type: string OS_PLATFORM: - required: false - description: Default OS/Arch + required: true + description: OS/Codename/Arch default: amd64 type: string outputs: @@ -38,7 +38,7 @@ jobs: meta: runs-on: ${{ inputs.RUNNER }} - name: Generate metadata for ${{inputs.LIB_NAME}} + name: Generate metadata for ${{ inputs.LIB_NAME }} environment: ${{ inputs.ENVIRONMENT }} steps: @@ -60,6 +60,6 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: ${{inputs.OS_PLATFORM}}-meta + name: ${{ inputs.OS_PLATFORM }}-meta path: | metafile.txt