|
| 1 | +name: post-release |
| 2 | + |
| 3 | +on: |
| 4 | + # release: |
| 5 | + # types: |
| 6 | + # - published |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Release tag to process (optional)' |
| 11 | + required: true |
| 12 | + # default: '' |
| 13 | + |
| 14 | +env: |
| 15 | + NODE_VERSION: 22.6.0 |
| 16 | + PNPM_VERSION: 9.7.1 |
| 17 | + DO_NOT_TRACK: 1 # Disable Turbopack telemetry |
| 18 | + NEXT_TELEMETRY_DISABLED: 1 # Disable Next telemetry |
| 19 | + |
| 20 | +jobs: |
| 21 | + update_templates: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: write |
| 25 | + pull-requests: write |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + - name: Setup |
| 30 | + uses: ./.github/actions/setup |
| 31 | + with: |
| 32 | + node-version: ${{ env.NODE_VERSION }} |
| 33 | + pnpm-version: ${{ env.PNPM_VERSION }} |
| 34 | + |
| 35 | + - name: Start PostgreSQL |
| 36 | + uses: CasperWA/postgresql-action@v1.2 |
| 37 | + with: |
| 38 | + postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions |
| 39 | + postgresql db: ${{ env.POSTGRES_DB }} |
| 40 | + postgresql user: ${{ env.POSTGRES_USER }} |
| 41 | + postgresql password: ${{ env.POSTGRES_PASSWORD }} |
| 42 | + |
| 43 | + - name: Wait for PostgreSQL |
| 44 | + run: sleep 30 |
| 45 | + |
| 46 | + - name: Configure PostgreSQL |
| 47 | + run: | |
| 48 | + psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "CREATE ROLE runner SUPERUSER LOGIN;" |
| 49 | + psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "SELECT version();" |
| 50 | + echo "POSTGRES_URL=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" >> $GITHUB_ENV |
| 51 | +
|
| 52 | + - name: Start MongoDB |
| 53 | + uses: supercharge/mongodb-github-action@1.11.0 |
| 54 | + with: |
| 55 | + mongodb-version: 6.0 |
| 56 | + |
| 57 | + - name: Update template lockfiles and migrations |
| 58 | + run: pnpm script:gen-templates |
| 59 | + |
| 60 | + - name: Determine Release Tag |
| 61 | + id: determine_tag |
| 62 | + run: | |
| 63 | + if [ "${{ github.event.inputs.tag }}" != "" ]; then |
| 64 | + echo "Using tag from input: ${{ github.event.inputs.tag }}" |
| 65 | + echo "release_tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" |
| 66 | + else |
| 67 | + echo "Using tag from release event: ${{ github.event.release.tag_name }}" |
| 68 | + echo "release_tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT" |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Commit and push changes |
| 72 | + id: commit |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + run: | |
| 76 | + set -ex |
| 77 | + git config --global user.name "github-actions[bot]" |
| 78 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 79 | + export BRANCH_NAME=chore/templates-${{ steps.determine_tag.outputs.release_tag }} |
| 80 | + git checkout -b $BRANCH_NAME |
| 81 | + git add -A |
| 82 | +
|
| 83 | + # If no files have changed, exit early with success |
| 84 | + git diff --cached --quiet --exit-code && exit 0 |
| 85 | +
|
| 86 | + git commit -m "chore(templates): bump lockfiles after ${{ steps.determine_tag.outputs.release_tag }}" |
| 87 | + git push origin $BRANCH_NAME |
| 88 | + echo "committed=true" >> "$GITHUB_OUTPUT" |
| 89 | + echo "branch=$BRANCH_NAME" >> "$GITHUB_OUTPUT" |
| 90 | +
|
| 91 | + - name: Debug Branches |
| 92 | + run: | |
| 93 | + echo "Target Commitish: ${{ github.event.release.target_commitish }}" |
| 94 | + echo "Branch: ${{ steps.commit.outputs.branch }}" |
| 95 | + echo "Ref: ${{ github.ref }}" |
| 96 | +
|
| 97 | + - name: Create pull request |
| 98 | + uses: peter-evans/create-pull-request@v7 |
| 99 | + if: steps.commit.outputs.committed == 'true' |
| 100 | + with: |
| 101 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + labels: 'area: templates' |
| 103 | + author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> |
| 104 | + commit-message: 'Automated update after release' |
| 105 | + branch: ${{ steps.commit.outputs.branch }} |
| 106 | + base: ${{ github.event_name != 'workflow_dispatch' && github.event.release.target_commitish || github.ref }} |
| 107 | + title: 'chore(templates): bump lockfiles after ${{ steps.determine_tag.outputs.release_tag }}' |
| 108 | + body: 'Automated bump of template lockfiles after release ${{ steps.determine_tag.outputs.release_tag }}' |
0 commit comments