Generate and Sync Files #820
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
# Be aware: This workflow should be kept in sync with generate-and-deploy-with-delete.yml and generate-and-deploy-recent.yml | |
name: Generate and Sync Files | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: The environment of the Registry | |
options: | |
- Development | |
- Production | |
jobs: | |
generate-and-sync: | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ inputs.environment || 'Production' }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: './src/go.mod' | |
cache-dependency-path: './src/go.sum' | |
- name: Setup dependencies | |
run: sudo apt-get update && sudo apt-get install rclone | |
- name: Run Generation script | |
working-directory: ./src | |
run: go run ./cmd/generate-v1 --destination ../generated | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
## Note for developers consuming this: This action is sometimes expected to error | |
## When the max-delete threshold is reached at 0. This is an indication that the | |
## bucket is not in sync with the local files. This is expected behavior and is a signal that we should | |
## manually run the generate-and-deploy-with-delete.yml workflow to ensure the bucket is in sync. | |
## The sync will have happened and new files will be updated in the bucket, but old files will not have been deleted. | |
- name: Sync Data to R2 | |
run: rclone sync --checkers=512 --transfers=512 --checksum --fast-list --max-delete 0 --delete-after ./generated R2:${{ secrets.R2_BUCKET_NAME }} | |
env: | |
# R2 credentials should be stored as GitHub secrets | |
RCLONE_CONFIG_R2_TYPE: s3 | |
RCLONE_CONFIG_R2_PROVIDER: Cloudflare | |
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} |