Skip to content

Commit c9ef35c

Browse files
committed
ci: Setup gitflow process (WIP)
1 parent 50817ac commit c9ef35c

6 files changed

+115
-14
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Build & Test'
22
on:
33
push:
44
branches:
5-
- master
5+
- develop
66
- release/**
77
pull_request:
88
workflow_dispatch:
@@ -42,11 +42,11 @@ env:
4242

4343
# GH will use the first restore-key it finds that matches
4444
# So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
45-
# We want to prefer the cache from the current master branch, if we don't find any on the current branch
45+
# We want to prefer the cache from the current develop branch, if we don't find any on the current branch
4646
NX_CACHE_RESTORE_KEYS: |
4747
nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }}
4848
nx-Linux-${{ github.ref }}
49-
nx-Linux-refs/heads/master
49+
nx-Linux-refs/heads/develop
5050
nx-Linux
5151
5252
jobs:
@@ -134,7 +134,7 @@ jobs:
134134
changed_browser_integration: ${{ steps.changed.outputs.browser_integration }}
135135
changed_any_code: ${{ steps.changed.outputs.any_code }}
136136
# Note: These next three have to be checked as strings ('true'/'false')!
137-
is_master: ${{ github.ref == 'refs/heads/master' }}
137+
is_develop: ${{ github.ref == 'refs/heads/develop' }}
138138
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
139139
force_skip_cache:
140140
${{ github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' ci-skip-cache ') }}
@@ -202,7 +202,7 @@ jobs:
202202
- name: NX cache
203203
uses: actions/cache@v3
204204
# Disable cache when:
205-
# - on master
205+
# - on develop
206206
# - on release branches
207207
# - when PR has `ci-skip-cache` label
208208
if: |
@@ -211,9 +211,9 @@ jobs:
211211
with:
212212
path: node_modules/.cache/nx
213213
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT }}
214-
# On master branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
214+
# On develop branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
215215
restore-keys:
216-
${{needs.job_get_metadata.outputs.is_master == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
216+
${{needs.job_get_metadata.outputs.is_develop == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
217217

218218
- name: Build packages
219219
# Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
@@ -272,8 +272,7 @@ jobs:
272272
needs: [job_get_metadata, job_build]
273273
timeout-minutes: 15
274274
runs-on: ubuntu-20.04
275-
# Size Check will error out outside of the context of a PR or master branch
276-
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_master == 'true'
275+
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_develop == 'true'
277276
steps:
278277
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
279278
uses: actions/checkout@v3
@@ -283,7 +282,6 @@ jobs:
283282
uses: actions/setup-node@v3
284283
with:
285284
# The size limit action runs `yarn` and `yarn build` when this job is executed on
286-
# `master`. We can't change this without making changes to the action, so we'll
287285
# use Node 14 for now.
288286
node-version: '14'
289287
- name: Check dependency cache
@@ -301,6 +299,7 @@ jobs:
301299
with:
302300
github_token: ${{ secrets.GITHUB_TOKEN }}
303301
skip_step: build
302+
main_branch: develop
304303

305304
job_lint:
306305
name: Lint

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ name: 'CodeQL'
1313

1414
on:
1515
push:
16-
branches: [master]
16+
branches: [develop]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [master]
19+
branches: [develop]
2020
paths-ignore:
2121
# When _only_ changing .md files, no need to run CodeQL analysis
2222
- '**/*.md'

.github/workflows/enforce-license-compliance.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Enforce License Compliance
22

33
on:
44
push:
5-
branches: [master, main, release/*]
5+
branches: [master, develop, release/*]
66
pull_request:
7-
branches: [master, main]
7+
branches: [master, develop]
88

99
jobs:
1010
enforce-license-compliance:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Gitflow - Sync master into develop
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
# When the version is updated on master (but nothing else)
8+
- 'lerna.json'
9+
- '!**/*.js'
10+
- '!**/*.json'
11+
- '!**/*.ts'
12+
13+
env:
14+
DEV_BRANCH: develop
15+
16+
jobs:
17+
main:
18+
name: Create PR develop->master
19+
runs-on: ubuntu-20.04
20+
permissions:
21+
pull-requests: write
22+
steps:
23+
- name: git checkout
24+
uses: actions/checkout@v3
25+
26+
# https://github.com/marketplace/actions/github-pull-request-action
27+
- name: Create Pull Request
28+
id: open-pr
29+
uses: repo-sync/pull-request@v2
30+
with:
31+
destination_branch: ${{ env.DEV_BRANCH }}
32+
pr_title: '[Gitflow] Merge ${{ github.ref_name }} into ${{ env.DEV_BRANCH }}'
33+
pr_body: 'Merge ${{ github.ref_name }} branch into ${{ env.DEV_BRANCH }}'
34+
35+
# https://github.com/marketplace/actions/enable-pull-request-automerge
36+
- name: Enable automerge for PR
37+
if: steps.open-pr.outputs.pr_number != ''
38+
uses: peter-evans/enable-pull-request-automerge@v2
39+
with:
40+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
41+
merge-method: merge
42+
43+
# https://github.com/marketplace/actions/auto-approve
44+
- name: Auto approve PR
45+
uses: hmarr/auto-approve-action@v3
46+
with:
47+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
48+
review-message: 'Auto approved automated PR'
49+
# TODO: Use the token of some user here??
50+
# github-token: ${{ secrets.SOME_USERS_PAT }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Gitflow - Sync develop into master
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
paths:
7+
# We want to trigger this when ONLY the changlog is changed on develop, but nothing else
8+
- 'CHANGELOG.md'
9+
- '!packages'
10+
- '!**/*.js'
11+
- '!**/*.json'
12+
- '!**/*.ts'
13+
14+
env:
15+
MAIN_BRANCH: master
16+
17+
jobs:
18+
main:
19+
name: Create PR develop->master
20+
runs-on: ubuntu-20.04
21+
permissions:
22+
pull-requests: write
23+
steps:
24+
- name: git checkout
25+
uses: actions/checkout@v3
26+
27+
# https://github.com/marketplace/actions/github-pull-request-action
28+
- name: Create Pull Request
29+
id: open-pr
30+
uses: repo-sync/pull-request@v2
31+
with:
32+
destination_branch: ${{ env.MAIN_BRANCH }}
33+
pr_title: '[Gitflow] Merge ${{ github.ref_name }} into ${{ env.MAIN_BRANCH }}'
34+
pr_body: 'Merge ${{ github.ref_name }} branch into ${{ env.MAIN_BRANCH }}'
35+
36+
# https://github.com/marketplace/actions/enable-pull-request-automerge
37+
- name: Enable automerge for PR
38+
if: steps.open-pr.outputs.pr_number != ''
39+
uses: peter-evans/enable-pull-request-automerge@v2
40+
with:
41+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
42+
merge-method: merge
43+
44+
# https://github.com/marketplace/actions/auto-approve
45+
- name: Auto approve PR
46+
uses: hmarr/auto-approve-action@v3
47+
with:
48+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
49+
review-message: 'Auto approved automated PR'
50+
# TODO: Use the token of some user here??
51+
# github-token: ${{ secrets.SOME_USERS_PAT }}

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
merge_target:
1212
description: Target branch to merge into. Uses the default branch as a fallback (optional)
1313
required: false
14+
default: master
1415
jobs:
1516
release:
1617
runs-on: ubuntu-20.04

0 commit comments

Comments
 (0)