generated from probot/example-github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (86 loc) · 3.34 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
name: Main
'on':
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, ready_for_review, reopened, synchronize]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: corepack enable
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: pnpm
node-version-file: package.json
- run: pnpm install --frozen-lockfile --ignore-scripts
- name: Check formatting
run: pnpm check-format
- run: pnpm test
release:
env:
DRY_RUN: ${{ github.ref_name != github.event.repository.default_branch }}
name: Release
needs: test
runs-on: ubuntu-latest
steps:
- id: get-workflow-access-token
name: Get Workflow Access Token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
with:
app-id: ${{ secrets.APPLICATION_ID }}
private-key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
- name: Setup Git user
run: |
git config --global user.email '118100583+bfra-me[bot]@users.noreply.github.com'
git config --global user.name 'bfra-me[bot]'
- name: Checkout `release` branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
ref: release
token: ${{ steps.get-workflow-access-token.outputs.token }}
- if: ${{ github.event_name == 'pull_request' }}
name: Fetch PR
run: git fetch origin +${{ github.sha }}:${{ github.ref }}
- id: merge
name: Merge `main` into `release`
run: |
git merge --no-ff -Xtheirs -m 'skip: merge (${{ github.sha }}) [skip release]' ${{ github.sha }}
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: pnpm
node-version-file: package.json
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- if: env.DRY_RUN != 'true'
name: Push `release` branch
run: git push origin release:release
- env:
GIT_AUTHOR_EMAIL: '118100583+bfra-me[bot]@users.noreply.github.com'
GIT_AUTHOR_NAME: 'bfra-me[bot]'
GIT_COMMITTER_EMAIL: '118100583+bfra-me[bot]@users.noreply.github.com'
GIT_COMMITTER_NAME: 'bfra-me[bot]'
GITHUB_TOKEN: ${{ steps.get-workflow-access-token.outputs.token }}
id: semantic-release
name: Semantic Release
run: |
export GITHUB_REF=refs/heads/release GITHUB_SHA=${{ steps.merge.outputs.commit }}
pnpm semantic-release --dry-run ${{ env.DRY_RUN }} --ci ${{ env.DRY_RUN != 'true' }}
- if: github.event_name == 'push' && env.DRY_RUN != 'true'
run: 'git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git refs/heads/release:refs/heads/v1'
env:
GITHUB_TOKEN: ${{ steps.get-workflow-access-token.outputs.token }}