From 4bb3937ff88299f867ae9c8505d4d8aeef705f46 Mon Sep 17 00:00:00 2001 From: Philip de Nier Date: Thu, 3 Oct 2024 09:37:16 +0100 Subject: [PATCH] Use local shared-ext-update-static-files-workflow.yml --- ...hared-ext-update-static-files-workflow.yml | 87 +++++++++++++++++++ .../update-static-files-workflow.yml | 2 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/shared-ext-update-static-files-workflow.yml diff --git a/.github/workflows/shared-ext-update-static-files-workflow.yml b/.github/workflows/shared-ext-update-static-files-workflow.yml new file mode 100644 index 0000000..1ea656b --- /dev/null +++ b/.github/workflows/shared-ext-update-static-files-workflow.yml @@ -0,0 +1,87 @@ +name: Shared Update Static Files Workflow +on: + workflow_call: + inputs: + commontoolingBranch: + description: 'Commontooling branch or tag to use' + required: true + default: 'main' + type: string + secrets: + WRITE_ACCESS_DEPLOY_KEY: + description: 'A deploy key that is used to checkout code with write access' + required: true + COMMONTOOLING_DEPLOY_KEY: + description: 'A deploy key that is used to fetch Commontooling' + required: true + +env: + COMMONTOOLING_BRANCH: ${{ inputs.commontoolingBranch == '' && 'main' || inputs.commontoolingBranch }} + +jobs: + UpdateStaticFiles: + permissions: + contents: read + runs-on: ubuntu-22.04 + environment: + name: update-static-files + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + fetch-depth: 1 + ssh-key: ${{ secrets.WRITE_ACCESS_DEPLOY_KEY }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + with: + registry-type: public + mask-password: true + + - name: Initialise commontooling + uses: actions/checkout@v4 + with: + repository: bbc/rd-cloudfit-commontooling + ref: ${{ env.COMMONTOOLING_BRANCH }} + path: commontooling + fetch-depth: 1 + ssh-key: ${{ secrets.COMMONTOOLING_DEPLOY_KEY }} + + - name: Configure git user info + run: | + git config --local user.email "github-actions@github.com" + git config --local user.name "GitHub Actions" + + - name: Update static files + run: | + make static-files + + - name: Show git status + run: | + git status + + - name: Commit static file changes + id: commitStaticFileChanges + run: | + git add . + if git commit -a -m "Regenerate static files" + then + echo "haveChanges=true" >> $GITHUB_OUTPUT; + else + echo "haveChanges=false" >> $GITHUB_OUTPUT; + fi + + - name: Push static file changes + if: ${{ steps.commitStaticFileChanges.outputs.haveChanges == 'true' }} + run: | + git push + + - name: Adding summary + run: | + if [ '${{ steps.commitStaticFileChanges.outputs.haveChanges }}' == 'true' ] + then + echo "The static files have been updated" >> $GITHUB_STEP_SUMMARY + else + echo "There are no static file updates" >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/update-static-files-workflow.yml b/.github/workflows/update-static-files-workflow.yml index 6d7dbd1..805e2db 100644 --- a/.github/workflows/update-static-files-workflow.yml +++ b/.github/workflows/update-static-files-workflow.yml @@ -15,7 +15,7 @@ jobs: permissions: contents: read # Github Actions doesn't allow the use of parameters in `uses` statements. If you want to use a different shared workflow branch, change it here - uses: bbc/rd-cloudfit-commontooling/.github/workflows/shared-update-static-files-workflow.yml@main + uses: ./.github/workflows/shared-ext-update-static-files-workflow.yml with: commontoolingBranch: ${{ inputs.commontoolingBranch || 'main' }} secrets: inherit