From e719fc1c9fd129d9ad287f22c0fbb9c0242524f0 Mon Sep 17 00:00:00 2001 From: John Henderson Date: Mon, 5 Feb 2024 09:23:48 +0000 Subject: [PATCH] feat(refresh-coda-cache workflow): add workflow. (#356) --- .github/workflows/refresh-coda-cache.yml | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/refresh-coda-cache.yml diff --git a/.github/workflows/refresh-coda-cache.yml b/.github/workflows/refresh-coda-cache.yml new file mode 100644 index 00000000..f74ec7f5 --- /dev/null +++ b/.github/workflows/refresh-coda-cache.yml @@ -0,0 +1,39 @@ +name: Refresh Coda Cache +on: + workflow_dispatch +jobs: + refresh-coda: + runs-on: ubuntu-latest + env: + CODA_TOKEN: ${{ secrets.CODA_TOKEN }} + filepath: app/mocks/coda-responses + filename: cached-coda-responses.json + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - id: download + name: Download updated data from Coda + run: | + npm ci + npm run refresh-test-data + OUTPUT=$(git diff --name-only | tail -1) + echo "::set-output name=gitdiff::$OUTPUT" + - id: check + name: Check for changes + run: | + echo "git diff --name-only | tail -1 >>> ${{ steps.download.outputs.gitdiff }}" + echo "cached data changed = ${{ contains( steps.download.outputs.gitdiff, env.filename ) }}" + echo "::set-output name=changed::${{ contains( steps.download.outputs.gitdiff, env.filename ) }}" + - if: steps.check.outputs.changed == 'true' + name: Commit files + run: | + git config --local user.name ${{ github.actor }} + git config --local user.email ${{ github.actor }}@users.noreply.github.com + git stage ${{ env.filepath }}/${{ env.filename }} + git commit -m "Update ${{ env.filename }}" + - if: steps.check.outputs.changed == 'true' + name: Push updated files on GitHub + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.PUSH_AUTH_TOKEN }}