Repository navigation
125 lines (103 loc) · 3.42 KB
/
Copy pathon-push.yml
File metadata and controls
125 lines (103 loc) · 3.42 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: CI
on:
push:
branches:
- 'main'
- 'v8'
- 'v10.0'
pull_request:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
lint_test_generate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
- name: Setup node ${{ steps.nvm.outputs.NVMRC }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ steps.nvm.outputs.NVMRC }}
- run: echo 'dummytoken' > ./accesstoken
working-directory: example
- name: Install
run: yarn install --network-timeout 1000000
- name: Lint
run: yarn lint
- name: Type check
run: yarn type:check
- name: Example/install
run: yarn install --network-timeout 1000000
working-directory: example
- name: Example type check
run: yarn type:check
working-directory: example
- name: Test
run: yarn unittest
- name: Generate
run: yarn generate
outputs:
NVMRC: ${{ steps.nvm.outputs.NVMRC }}
changes:
runs-on: ubuntu-latest
outputs:
web-only: ${{ steps.diff.outputs.web-only }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect web-only changes
id: diff
if: github.event_name == 'pull_request'
env:
BASE_REF: ${{ github.base_ref }}
run: |
changed=$(git diff --name-only "origin/$BASE_REF...HEAD")
echo "$changed"
if [ -n "$changed" ] && ! echo "$changed" | grep -qv '^src/web/'; then
echo "web-only=true" >> "$GITHUB_OUTPUT"
fi
has_mapbox_token:
runs-on: ubuntu-latest
outputs:
has-mapbox-token: ${{ steps.has-mapbox-token.outputs.defined }}
steps:
- id: has-mapbox-token
env:
MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
if: "${{ env.MAPBOX_ACCESS_TOKEN != '' }}"
run: echo "::set-output name=defined::true"
call_ci_requiring_tokens:
name: "CI requiring tokens"
needs: [lint_test_generate,has_mapbox_token,changes]
uses: ./.github/workflows/ci-requiring-tokens.yml
with:
NVMRC: ${{ needs.lint_test_generate.outputs.NVMRC }}
SKIP_NATIVE: ${{ needs.changes.outputs.web-only == 'true' }}
# Fork PRs have no secrets but can still build with the public rotated CI token,
# so always run in rnmapbox/maps; forks of the repo still need their own token.
if: needs.has_mapbox_token.outputs.has-mapbox-token == 'true' || github.repository == 'rnmapbox/maps'
secrets:
MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
publish:
if: startsWith(github.ref, 'refs/tags/') && (github.event_name == 'push')
needs: [lint_test_generate]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup node ${{ steps.nvm.outputs.NVMRC }}
uses: actions/setup-node@v3.5.1
with:
node-version: ${{ needs.lint_test_generate.outputs.NVMRC }}
registry-url: https://registry.npmjs.org/
- name: Install and Publish
run: npm install --force && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}