Skip to content

Commit

Permalink
added website CDN cache purge
Browse files Browse the repository at this point in the history
  • Loading branch information
rstaib committed Oct 14, 2023
1 parent ba80eee commit c724d3c
Showing 1 changed file with 51 additions and 44 deletions.
95 changes: 51 additions & 44 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,63 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Docker Login
uses: docker/login-action@v2
with:
registry: ${{ secrets.CONTAINER_REG_URL }}
username: ${{ secrets.CONTAINER_REG_USERNAME }}
password: ${{ secrets.CONTAINER_REG_PASSWORD }}
- name: Docker Login
uses: docker/login-action@v2
with:
registry: ${{ secrets.CONTAINER_REG_URL }}
username: ${{ secrets.CONTAINER_REG_USERNAME }}
password: ${{ secrets.CONTAINER_REG_PASSWORD }}

- run: echo ${{ secrets.CONTAINER_REG_URL }}
- run: echo ${{ secrets.CONTAINER_REG_URL }}

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
cache: 'yarn'
cache-dependency-path: 'website/yarn.lock'
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: "18.x"
cache: "yarn"
cache-dependency-path: "website/yarn.lock"

- name: Cache Yarn Packages
uses: actions/cache@v3
with:
path: |
website/.yarn/cache
website/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('website/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache Yarn Packages
uses: actions/cache@v3
with:
path: |
website/.yarn/cache
website/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('website/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Packages
run: yarn --immutable --network-timeout 100000
working-directory: website
- name: Install Packages
run: yarn --immutable --network-timeout 100000
working-directory: website

- name: Build Website
run: yarn build --prefix-paths
working-directory: website
- name: Build Website
run: yarn build --prefix-paths
working-directory: website

- name: Build WebSite Container
uses: docker/build-push-action@v2
with:
context: .
file: .docker/website/dockerfile
push: true
tags: ${{ secrets.CONTAINER_REG_DOMAIN }}/ccc-website-${{ github.ref_name }}:${{ github.run_id }}
- name: Build WebSite Container
uses: docker/build-push-action@v2
with:
context: .
file: .docker/website/dockerfile
push: true
tags: ${{ secrets.CONTAINER_REG_DOMAIN }}/ccc-website-${{ github.ref_name }}:${{ github.run_id }}

- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v2
with:
app-name: ccc-p-us1-website
slot-name: 'production'
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
images: ${{ secrets.CONTAINER_REG_DOMAIN }}/ccc-website-${{ github.ref_name }}:${{ github.run_id }}
- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v2
with:
app-name: ccc-p-us1-website
slot-name: "production"
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
images: ${{ secrets.CONTAINER_REG_DOMAIN }}/ccc-website-${{ github.ref_name }}:${{ github.run_id }}

- name: Purge CDN Cache
run: |
curl --request POST \
--url https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE_ID }}/purge_cache \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${{ secrets.CLOUDFLARE_AUTH_TOKEN }}' \
--data '{ "purge_everything": true }'

0 comments on commit c724d3c

Please sign in to comment.