-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (67 loc) · 2.86 KB
/
_resolve-yarn-lock.yml
File metadata and controls
77 lines (67 loc) · 2.86 KB
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
name: Resolve yarn.lock
on:
workflow_call:
inputs:
pr_number:
required: true
type: number
repo:
required: true
type: string
secrets:
TXO_GITHUB_BOT_APP_ID:
required: true
TXO_GITHUB_BOT_APP_PRIVATE_KEY:
required: true
jobs:
resolve-yarn-lock:
name: "/"
runs-on: ubuntu-latest
steps:
- uses: technology-studio/github-workflows/.github/actions/github-app-token-generator@696ee6d68a8fdb357c5a6e26e748fba32f09a9bb # main
id: get-token
with:
app-id: ${{ secrets.TXO_GITHUB_BOT_APP_ID }}
private-key: ${{ secrets.TXO_GITHUB_BOT_APP_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
token: ${{ steps.get-token.outputs.token }}
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version-file: '.nvmrc'
- name: Get PR branch names
env:
REPO: ${{ inputs.repo }}
PR_NO: ${{ inputs.pr_number }}
GH_TOKEN: ${{ github.token }}
run: |
echo "HEAD_BRANCH=$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')" >> $GITHUB_ENV
echo "BASE_BRANCH=$(gh pr view $PR_NO --repo $REPO --json baseRefName --jq '.baseRefName')" >> $GITHUB_ENV
- name: Fetch all commits from PR and base branches
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ env.HEAD_BRANCH }}:refs/remotes/origin/${{ env.HEAD_BRANCH }}
git fetch --no-tags --prune --deepen=999999 origin +refs/heads/${{ env.HEAD_BRANCH }}:refs/remotes/origin/${{ env.HEAD_BRANCH }}
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ env.BASE_BRANCH }}:refs/remotes/origin/${{ env.BASE_BRANCH }}
git fetch --no-tags --prune --deepen=999999 origin +refs/heads/${{ env.BASE_BRANCH }}:refs/remotes/origin/${{ env.BASE_BRANCH }}
- name: Checkout PR branch and merge base branch
run: |
git config --global user.email "txo-github-bot[bot]@users.noreply.github.com"
git config --global user.name "TXO GitHub Bot[bot]"
git checkout ${{ env.HEAD_BRANCH }}
git merge origin/${{ env.BASE_BRANCH }} || true
- name: Check for merge conflict on yarn.lock file
run: |
YARN_LOCK_HAS_CONFLICTS=$(git ls-files -u | grep yarn.lock | wc -l)
echo "YARN_LOCK_HAS_CONFLICTS=$YARN_LOCK_HAS_CONFLICTS" >> $GITHUB_ENV
- name: Run yarn install to resolve conflicts automatically
if: env.YARN_LOCK_HAS_CONFLICTS > 0
run: |
yarn install
- name: Commit yarn.lock
run: |
git add yarn.lock
git commit -m "chore: resolve yarn.lock"
- name: Push yarn.lock
run: |
git push