-
-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (130 loc) · 5.84 KB
/
checks.yml
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
###############################################################################
# RELEASE
###############################################################################
name: ✅ Tests and check for updates
on:
pull_request:
branches:
- main
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
###############################################################################
# JOBS
###############################################################################
jobs:
checks:
runs-on: ubuntu-latest
steps:
#########################################################################
# INIT
#########################################################################
- name: ⬇️🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
- name: ⬇️🛎 Checkout
uses: actions/checkout@v4
- name: ⬇️🥡 Install pnpm
uses: pnpm/action-setup@v4
- name: ⬇️🟢 Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: 🐙😺 Check GitHub API Rate Limit
id: rate_limit
run: |
response=$(gh api rate_limit)
limit=$(echo $response | jq -r '.resources.core.limit')
remaining=$(echo $response | jq -r '.resources.core.remaining')
echo "GitHub API Rate Limit: $remaining/$limit"
if [ "$remaining" -lt 10 ]; then
exit 1
fi
env:
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: ⬇️📦 Install dependencies
run: pnpm install --no-frozen-lockfile
- name: ⬇️🌐 Install Playwright Browsers
run: pnpx playwright install --with-deps
#########################################################################
# BUILD
#########################################################################
- name: 🏗 Build packages
run: pnpm build
#########################################################################
# TEST
#########################################################################
- name: ✅ Run [e2e & unit] tests
run: pnpm test
#########################################################################
# EXIT IF IS PULL REQUEST
#########################################################################
- name: 🚪 Exit here if is pull request
if: github.event_name == 'pull_request'
run: |
echo "Pull request detected, exiting..."
exit 0
env:
GITHUB_TOKEN: ${{env.GITHUB_TOKEN }}
#########################################################################
#########################################################################
# UPDATE VERSIONS
#########################################################################
#########################################################################
- name: 📣 Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
title: "chore(release): version packages 🦋"
publish: pnpm . pkg publish --silent
version: pnpm . pkg publish version --silent
commit: "chore(release): version packages 🦋 [skip ci]"
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
NPM_TOKEN: ${{ env.NPM_TOKEN }}
- name: Get updated versions if exists
id: updated
run: |
docs_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | select(.name == "@backan/docs") | .version')
core_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r 'map(select(.name == "@backan/core" or .name == "@backan/builder" or .name == "@backan/server")) | .[0].version // empty' )
core_version_major=${core_version%%.*}
echo Set changesets outputs
echo '${{ toJSON(steps.changesets.outputs) }}'
echo Set updated versions
echo "CORE=$core_version CORE_MAJOR=$core_version_major DOCS=$docs_version"
echo "core_version=$core_version" >> $GITHUB_OUTPUT
echo "docs_version=$docs_version" >> $GITHUB_OUTPUT
echo "core_version_major=$core_version_major" >> $GITHUB_OUTPUT
- name: Add core version TAG to Github
if: steps.updated.outputs.core_version != ''
uses: richardsimko/update-tag@v1
with:
tag_name: ${{steps.updated.outputs.core_version}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#########################################################################
# UPDATE REPO INFO
#########################################################################
- name: ℹ️➡️ Check for changes in package.json
run: |
git fetch origin main
git diff --name-only HEAD origin/main | grep 'package.json' || echo "No changes in package.json"
continue-on-error: true
id: check_package_json
- name: ℹ️🐙😺➡️ Update repo info
if: steps.check_package_json.outputs.stdout != 'No changes in package.json'
run: pnpm . gh info update
continue-on-error: true
#########################################################################
# CALL TO WORKFLOWS
#########################################################################
- name: 📚🐙😺➡️ Call to workflow for deploy Documentation
if: steps.updated.outputs.docs_version != ''
uses: benc-uk/workflow-dispatch@v1
with:
workflow: release-docs.yml
continue-on-error: true
###############################################################################