Update #1042
This file contains hidden or 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: Update | |
| permissions: {} | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| concurrency: | |
| group: "${{ github.workflow }}-${{ github.ref }}" | |
| cancel-in-progress: true | |
| env: | |
| MAX_NEW_ASSETS: 50 # Set to 0 for unlimited, or any positive number to limit downloads per run | |
| jobs: | |
| update: | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Check dist branch | |
| id: dist_branch | |
| run: | | |
| if git ls-remote --exit-code --heads origin dist >/dev/null; then | |
| echo "exists=true" >> "${GITHUB_OUTPUT}" | |
| else | |
| status=$? | |
| if [ "$status" -ne 2 ]; then | |
| exit "$status" | |
| fi | |
| echo "exists=false" >> "${GITHUB_OUTPUT}" | |
| fi | |
| - name: Checkout dist branch | |
| if: steps.dist_branch.outputs.exists == 'true' | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| ref: dist | |
| path: dist | |
| persist-credentials: false # otherwise, pushes use GITHUB_TOKEN instead of the personal token | |
| fetch-depth: 1 | |
| - name: Create dist branch | |
| if: steps.dist_branch.outputs.exists == 'false' | |
| run: | | |
| mkdir dist | |
| cd dist | |
| git init --initial-branch=dist | |
| git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git" | |
| - name: Get organization repositories, download assets, and update package index | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| github-token: ${{ secrets.GH_BOT_TOKEN || github.token }} | |
| script: | | |
| // Import the sync assets with metadata module | |
| const { syncAssetsWithMetadata } = require('./.github/scripts/sync-assets-with-metadata.js'); | |
| // Check if this is a pull request event | |
| const isPullRequest = context.eventName === 'pull_request'; | |
| // Get the max new assets limit from environment | |
| const maxNewAssets = parseInt(process.env.MAX_NEW_ASSETS) || 0; | |
| // Change working directory to dist for file operations | |
| process.chdir('./dist'); | |
| // Run the asset synchronization and write packages.json | |
| await syncAssetsWithMetadata(github, context, isPullRequest, maxNewAssets); | |
| - name: GitHub Commit & Push | |
| if: github.event_name != 'pull_request' | |
| uses: actions-js/push@968f4695ca558093eadb24ad83cc5891f47e0cdc # v1.6 | |
| with: | |
| amend: ${{ steps.dist_branch.outputs.exists == 'true' }} | |
| author_email: ${{ secrets.GH_BOT_EMAIL }} | |
| author_name: ${{ vars.GH_BOT_NAME }} | |
| branch: dist | |
| directory: dist | |
| force: ${{ steps.dist_branch.outputs.exists == 'true' }} | |
| github_token: ${{ secrets.GH_BOT_TOKEN }} | |
| message: 'Update release assets' | |
| - name: Prepare artifact | |
| run: | | |
| cd gh-pages-template | |
| 7z a ../build.zip . | |
| cd ../dist | |
| 7z a ../build.zip . "-xr!.git" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: update | |
| path: build.zip | |
| if-no-files-found: error | |
| include-hidden-files: true | |
| retention-days: 1 | |
| call-jekyll-build: | |
| needs: update | |
| permissions: | |
| contents: read | |
| uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master | |
| secrets: | |
| GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }} | |
| GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} | |
| with: | |
| clean_gh_pages: true | |
| extract_archive: 'build.zip' | |
| gh_bot_name: ${{ vars.GH_BOT_NAME }} | |
| site_artifact: 'update' | |
| target_branch: 'gh-pages' |