From a1710b17c81a82e673ca7324729306d5cae52d0a Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Mon, 29 Apr 2024 11:29:00 +0100 Subject: [PATCH] Take out cloudfront cache busting into a separate github action --- .github/workflows/cloudfront-cache.yml | 20 ++++++++++++++++++++ .github/workflows/deployment.yml | 15 +-------------- 2 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/cloudfront-cache.yml diff --git a/.github/workflows/cloudfront-cache.yml b/.github/workflows/cloudfront-cache.yml new file mode 100644 index 000000000..52b3e1056 --- /dev/null +++ b/.github/workflows/cloudfront-cache.yml @@ -0,0 +1,20 @@ +name: Clears Cloudfront Cache +on: + # Allow manual Run + workflow_dispatch: + # Run at midnight utc + schedule: + - cron: '0 0 * * *' +jobs: + aws_costs: + runs-on: ubuntu-latest + steps: + - name: Clear Cloudfront Caching + run: | + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GH_PAT }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/roadmapsh/infra-ansible/actions/workflows/playbook.yml/dispatches \ + -d '{ "ref":"master", "inputs": { "playbook": "roadmap_web.yml", "tags": "cloudfront", "is_verbose": false } }' diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 68b983e59..6f1a11924 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -59,17 +59,4 @@ jobs: key: ${{ secrets.EC2_PRIVATE_KEY }} script: | cd /var/www/roadmap.sh - sudo pm2 restart web-roadmap - - # -------------------- - # Clear Cloudfront Caching - # -------------------- - - name: Clear Cloudfront Caching - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GH_PAT }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/roadmapsh/infra-ansible/actions/workflows/playbook.yml/dispatches \ - -d '{ "ref":"master", "inputs": { "playbook": "roadmap_web.yml", "tags": "cloudfront", "is_verbose": false } }' \ No newline at end of file + sudo pm2 restart web-roadmap \ No newline at end of file