Skip to content

Merge branch 'feature/CSC-1652-gh-action-for-processing-custom-sheets… #34

Merge branch 'feature/CSC-1652-gh-action-for-processing-custom-sheets…

Merge branch 'feature/CSC-1652-gh-action-for-processing-custom-sheets… #34

Workflow file for this run

name: Processes changed character-sheets and updates CDN bucket and/or sheet-http database as needed
on: push
env:
NPM_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
jobs:
staging-deployment:
if: github.ref == 'refs/heads/staging'
environment: staging
runs-on: ubuntu-latest
env:
CDN_SHEETS_FOLDER: ${{ vars.CDN_SHEETS_FOLDER }}
# Set job outputs to values from filter step
outputs:
sheet: ${{ steps.filter.outputs.sheet }}
sheet-json: ${{ steps.filter.outputs.sheet_files }}
force-update: ${{ steps.filter.outputs.force-update }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
# Enable listing of files matching each filter.
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
# Paths will be escaped and space-delimited.
# Output is usable as command-line argument list in Linux shell
list-files: shell
filters: |
sheet:
- added|modified: '*/sheet.json'
force-update:
- added|modified: 'build.toml'
- id: 'auth'
if: steps.filter.outputs.sheet == 'true' || steps.filter.outputs.force-update == 'true'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.SHEET_HTTP_GCP_KEYFILE }}'
- name: 'Set up Cloud SDK'
if: steps.filter.outputs.sheet == 'true' || steps.filter.outputs.force-update == 'true'
uses: 'google-github-actions/setup-gcloud@v1'
- name: 'Use gcloud CLI'
if: steps.filter.outputs.sheet == 'true' || steps.filter.outputs.force-update == 'true'
run: 'gcloud info'
- uses: oven-sh/setup-bun@v1
if: steps.filter.outputs.sheet == 'true' || steps.filter.outputs.force-update == 'true'
- run: bun install
if: steps.filter.outputs.sheet == 'true' || steps.filter.outputs.force-update == 'true'
working-directory: contrib/sheet-pixie
# Handles when sheets have been updated individually
- run: DEST_DIR=${{ runner.temp }}/${{ env.CDN_SHEETS_FOLDER }} bun run contrib/sheet-pixie/index.ts ${{ needs.changes.outputs.sheet-json }}
if: steps.filter.outputs.sheet == 'true'
- run: gcloud storage rsync --project=roll20-actual ${{ runner.temp }}/${{ env.CDN_SHEETS_FOLDER }} gs://roll20-cdn/${{ env.CDN_SHEETS_FOLDER }} --cache-control='no-cache' --recursive
if: steps.filter.outputs.sheet == 'true'
# Handles when a force-update has been requested (meaning all sheets will be re-built and deployed)
- run: make all
if: steps.filter.outputs.force-update == 'true'
- run: gcloud storage rsync --project=roll20-actual ${{ runner.temp }}/${{ env.CDN_SHEETS_FOLDER }} gs://roll20-cdn/${{ env.CDN_SHEETS_FOLDER }} --delete-unmatched-destination-objects --cache-control='no-cache' --recursive
if: steps.filter.outputs.force-update == 'true'