Merge branch 'main' into staging #158
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Commit Stage | |
on: | |
push: | |
branches: ["staging"] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: cloud-native-nordics/kcddenmark.dk | |
VERSION: ${{ github.sha }} | |
GATSBY_DEFAULT_SITE_URL: https://kcddenmark.dk | |
jobs: | |
package: | |
name: Package and Publish | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
cache: "npm" | |
- name: Set up Pack CLI | |
uses: buildpacks/github-actions/[email protected] | |
- name: Install dependencies | |
run: npm ci | |
- name: Build SPA | |
run: | | |
npm run build | |
- name: Configure NGINX | |
run: | | |
cp nginx/* public/ | |
- name: Package SPA | |
run: | | |
pack build ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \ | |
--builder paketobuildpacks/builder-jammy-base \ | |
--path public | |
- name: Log into container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish container image | |
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | |
- name: Publish container image (latest) | |
run: | | |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \ | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
- name: Trigger watchtower to update running container | |
run: | | |
curl -H "Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}" https://watchtower.robert-jensen.dk/v1/update | |
purge-cache: | |
runs-on: ubuntu-latest | |
steps: | |
# Put steps here to build your site, deploy it to a service, etc. | |
- name: Purge cache | |
uses: jakejarvis/cloudflare-purge-action@master | |
env: | |
# Zone is required by both authentication methods | |
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }} | |
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} |