Generate Hashes JSON and Sync to Mirror #7
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: Generate Hashes JSON and Sync to Mirror | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| generate-hashes-and-sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Move Scripts to Root | |
| run: | | |
| mv .github/scripts/* ./ | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Use Node.js 24 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24.x | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run | |
| run: pnpm hash | |
| - name: Commit and push if changed | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add smallest_hashes.json | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: update hashes.json for tag ${{ github.ref_name }}" | |
| git push origin --all --force | |
| fi | |
| git tag -d LATEST 2>/dev/null || true | |
| git tag LATEST | |
| git push origin --tags --force | |
| - name: Add mirror remote (with token) | |
| env: | |
| MIRROR_URL: ${{ secrets.CNB_URL }} | |
| MIRROR_TOKEN: ${{ secrets.CNB_TOKEN }} | |
| run: | | |
| AUTH_URL=$(echo "$MIRROR_URL" | sed -E "s#^https://#https://x-access-token:${MIRROR_TOKEN}@#") | |
| git remote remove mirror 2>/dev/null || true | |
| git remote add mirror "$AUTH_URL" | |
| - name: Push all branches and tags | |
| run: | | |
| git push mirror --all --force | |
| git push mirror --tags --force |