Skip to content

Commit 0c34f27

Browse files
committed
ci: create separate post-release-templates workflow
1 parent 18f9f35 commit 0c34f27

File tree

2 files changed

+108
-67
lines changed

2 files changed

+108
-67
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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 }}'

.github/workflows/post-release.yml

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -50,70 +50,3 @@ jobs:
5050
color: '16777215'
5151
username: 'Payload Releases'
5252
avatar_url: 'https://l4wlsi8vxy8hre4v.public.blob.vercel-storage.com/discord-bot-logo.png'
53-
54-
update_templates:
55-
runs-on: ubuntu-latest
56-
permissions:
57-
contents: write
58-
pull-requests: write
59-
steps:
60-
- name: Checkout
61-
uses: actions/checkout@v4
62-
- name: Setup
63-
uses: ./.github/actions/setup
64-
with:
65-
node-version: ${{ env.NODE_VERSION }}
66-
pnpm-version: ${{ env.PNPM_VERSION }}
67-
68-
- name: Update template lockfiles and migrations
69-
run: pnpm script:gen-templates
70-
71-
- name: Determine Release Tag
72-
id: determine_tag
73-
run: |
74-
if [ "${{ github.event.inputs.tag }}" != "" ]; then
75-
echo "Using tag from input: ${{ github.event.inputs.tag }}"
76-
echo "release_tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
77-
else
78-
echo "Using tag from release event: ${{ github.event.release.tag_name }}"
79-
echo "release_tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
80-
fi
81-
82-
- name: Commit and push changes
83-
id: commit
84-
env:
85-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86-
run: |
87-
set -ex
88-
git config --global user.name "github-actions[bot]"
89-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
90-
export BRANCH_NAME=chore/templates-${{ steps.determine_tag.outputs.release_tag }}
91-
git checkout -b $BRANCH_NAME
92-
git add -A
93-
94-
# If no files have changed, exit early with success
95-
git diff --cached --quiet --exit-code && exit 0
96-
97-
git commit -m "chore(templates): bump lockfiles after ${{ steps.determine_tag.outputs.release_tag }}"
98-
git push origin $BRANCH_NAME
99-
echo "committed=true" >> "$GITHUB_OUTPUT"
100-
echo "branch=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
101-
102-
- name: Debug Branches
103-
run: |
104-
echo "Target Commitish: ${{ github.event.release.target_commitish }}"
105-
echo "Branch: ${{ steps.commit.outputs.branch }}"
106-
echo "Ref: ${{ github.ref }}"
107-
108-
- name: Create pull request
109-
uses: peter-evans/create-pull-request@v7
110-
if: steps.commit.outputs.committed == 'true'
111-
with:
112-
token: ${{ secrets.GITHUB_TOKEN }}
113-
labels: 'area: templates'
114-
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
115-
commit-message: 'Automated update after release'
116-
branch: ${{ steps.commit.outputs.branch }}
117-
base: ${{ github.event_name != 'workflow_dispatch' && github.event.release.target_commitish || github.ref }}
118-
title: 'chore(templates): bump lockfiles after ${{ steps.determine_tag.outputs.release_tag }}'
119-
body: 'Automated bump of template lockfiles after release ${{ steps.determine_tag.outputs.release_tag }}'

0 commit comments

Comments
 (0)