release #6
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: release | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: Override image tag (defaults to short SHA) | |
| required: false | |
| default: "" | |
| api_url: | |
| description: Browser-facing API URL baked into the build (REACT_ZFGBB_API_URL) | |
| required: false | |
| default: "https://api.bluedreamers.com/zfgbb" | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| IMAGE_NAME: zfgbb-react | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| outputs: | |
| tag: ${{ steps.meta.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Compute lowercase image ref + tag | |
| id: meta | |
| run: | | |
| set -euo pipefail | |
| echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE_NAME}" >> "$GITHUB_ENV" | |
| if [[ -n "${{ inputs.tag }}" ]]; then | |
| tag="${{ inputs.tag }}" | |
| else | |
| tag="${GITHUB_SHA::12}" | |
| fi | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| - uses: docker/setup-buildx-action@v4 | |
| - uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| target: app | |
| push: true | |
| provenance: false | |
| build-args: | | |
| REACT_ZFGBB_API_URL=${{ inputs.api_url || 'https://api.bluedreamers.com/zfgbb' }} | |
| tags: | | |
| ${{ env.IMAGE }}:${{ steps.meta.outputs.tag }} | |
| ${{ env.IMAGE }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| bump-argo: | |
| needs: build-and-push | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout argocd repo | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ZeldaFanGameCentral/argocd.zfgc.com | |
| token: ${{ secrets.PR_BUMP_TOKEN }} | |
| path: argocd | |
| - name: Bump image.tag in charts/zfgbb-react/values.yaml | |
| id: bump | |
| env: | |
| NEW_TAG: ${{ needs.build-and-push.outputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| cd argocd | |
| file=charts/zfgbb-react/values.yaml | |
| old_tag=$(awk '/^ tag:/{print $2; exit}' "$file" | tr -d '"') | |
| if [[ "$old_tag" == "$NEW_TAG" ]]; then | |
| echo "tag already $NEW_TAG; nothing to bump" | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| sed -i "0,/^ tag: .*/s|| tag: $NEW_TAG|" "$file" | |
| echo "old_tag=$old_tag" >> "$GITHUB_OUTPUT" | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| - name: Open PR | |
| if: steps.bump.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.PR_BUMP_TOKEN }} | |
| NEW_TAG: ${{ needs.build-and-push.outputs.tag }} | |
| OLD_TAG: ${{ steps.bump.outputs.old_tag }} | |
| run: | | |
| set -euo pipefail | |
| cd argocd | |
| branch="bump/zfgbb-react-$NEW_TAG" | |
| git config user.name 'zfgbb-react-release-bot' | |
| git config user.email 'zfgbb-react-release-bot@users.noreply.github.com' | |
| git checkout -b "$branch" | |
| git add charts/zfgbb-react/values.yaml | |
| msg=$(printf 'Bump zfgbb-react image to %s\n\nFrom: %s\nTo: %s\n' "$NEW_TAG" "$OLD_TAG" "$NEW_TAG") | |
| git commit -m "$msg" | |
| git push -u origin "$branch" | |
| gh pr create \ | |
| --base main \ | |
| --head "$branch" \ | |
| --title "Bump zfgbb-react image to $NEW_TAG" \ | |
| --body "Automated bump from \`$OLD_TAG\` to \`$NEW_TAG\` in \`charts/zfgbb-react/values.yaml\`. Built from $GITHUB_REPOSITORY@$GITHUB_SHA." |