webhook #37
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: "Nuxt Generate" | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
# Allows external webhook trigger | |
repository_dispatch: | |
types: | |
- webhook | |
jobs: | |
generate-static-html: | |
name: Generate static HTML files | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/scj2000/scj2000-web-v2/scj2000-web:latest | |
volumes: | |
- ${{ github.workspace }}/output/:/frontend/.output/ | |
env: | |
API_TOKEN: ${{ secrets.CMS_API_TOKEN }} | |
API_ENDPOINT: "${{ vars.CMS_API_ENDPOINT }}" | |
CDN_URL: "${{ vars.CDN_URL }}" | |
ASSETS_BASEURL: "${{ vars.ASSETS_BASEURL }}" | |
GTM_ID: "${{ vars.GTM_ID }}" | |
steps: | |
- name: Run the static site generate process with Docker | |
run: | | |
cd /frontend | |
npm run regenerate | |
- uses: actions/upload-artifact@master | |
with: | |
name: output-html | |
path: ${{ github.workspace }}/output/ | |
commit: | |
name: Commit changes | |
needs: generate-static-html | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set current date as env variable | |
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- uses: actions/download-artifact@master | |
with: | |
name: output-html | |
path: ${{ github.workspace }}/output/ | |
- name: Add and commit generated HTML | |
run: | | |
cd ${{ github.workspace }} | |
git config --global user.name 'scj2000 content update' | |
git config --global user.email 'webmaster@scj2000.net' | |
git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} | |
git add -A ./output/ | |
git commit -am "Content update $NOW" | |
git push | |