-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (85 loc) · 3.17 KB
/
autopr_merged.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
92
93
94
95
96
97
name: "Tag and release to production"
on:
pull_request:
types: [closed]
jobs:
tag-release:
runs-on: ubuntu-latest
if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged && (contains(github.event.pull_request.title, '[AUTO-PR]') || contains(github.event.pull_request.title, '[MANIFEST]'))
steps:
# Generate a bot token that will be used for all workflow actions.
# This is required as the default repo GITHUB_TOKEN does not trigger new workflow runs.
- name: Obtain a Notify PR Bot GitHub App Installation Access Token
run: |
TOKEN="$(npx [email protected] ci ${{ secrets.GH_APP_CREDENTIALS_TOKEN }})"
echo "::add-mask::$TOKEN"
echo "GITHUB_TOKEN=$TOKEN" >> $GITHUB_ENV
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@d745f2e74aaf1ee82e747b181f7a0967978abee0 # v6.0
with:
github_token: ${{ env.GITHUB_TOKEN }}
release_branches: main
- name: Checkout main branch
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
token: ${{ env.GITHUB_TOKEN }}
- name: Get current Prod Version
run: |
CURRENT_VERSION=`cat VERSION`
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Update version file
env:
NEW_VERSION: ${{ steps.tag_version.outputs.new_tag }}
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
run: |
echo $NEW_VERSION > VERSION
- name: setup git config
run: |
git config user.name "Notify PR Bot"
git config user.email "[email protected]"
- name: Branch protection OFF
uses: octokit/[email protected]
with:
route: PUT /repos/:repository/branches/main/protection
repository: ${{ github.repository }}
required_status_checks: |
null
required_linear_history: |
null
enforce_admins: |
null
required_pull_request_reviews: |
null
restrictions: |
null
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: commit
env:
NEW_VERSION: ${{ steps.tag_version.outputs.new_tag }}
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
run: |
git add VERSION
git commit -m "New release: ${CURRENT_VERSION} -> ${NEW_VERSION}"
git push origin main
- name: Branch protection ON
if: always()
uses: octokit/[email protected]
with:
route: PUT /repos/:repository/branches/main/protection
repository: ${{ github.repository }}
required_status_checks: |
strict: true
checks:
- context: testing_manifest
required_linear_history: |
true
enforce_admins: |
true
required_pull_request_reviews: |
required_approving_review_count: 1
restrictions: |
null
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}