99
1010jobs :
1111 setup :
12- if : " !contains(github.event.head_commit.message, 'skip ci')"
12+ if : " ${{ !contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'Release: Version Updates')}} "
1313 runs-on : ubuntu-latest
14+ permissions :
15+ actions : read
1416
1517 steps :
1618 - name : Checkout Code
17- uses : actions/checkout@v4
19+ uses : actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
1820 with :
19- token : ${{ secrets.BOT_TOKEN }}
2021 fetch-depth : 0
21- ref : " master"
22+ ref : ' master'
2223
2324 - name : Derive appropriate SHAs for base and head for `nx affected` commands
24- uses : nrwl/nx-set-shas@v3
25+ uses : nrwl/nx-set-shas@826660b82addbef3abff5fa871492ebad618c9e1 # v4.3.3
2526 with :
26- main-branch-name : " master"
27+ main-branch-name : ' master'
2728
2829 - name : Set Node Version
29- uses : actions/setup-node@v4
30+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3031 with :
3132 node-version : 22
32- cache : " yarn"
33- cache-dependency-path : " yarn.lock"
33+ cache : ' yarn'
34+ cache-dependency-path : ' yarn.lock'
3435
3536 # - name: Get yarn cache directory path
3637 # id: yarn-cache-dir-path
@@ -58,50 +59,40 @@ jobs:
5859 - name : Unit Tests
5960 run : yarn test:ci
6061
61- - name : Upload coverage report
62- uses : codecov/codecov-action@v3
63- with :
64- file : ./coverage/coverage-final.json
65- token : ${{ secrets.CODECOV_TOKEN }}
66-
6762 - name : Build Packages
6863 run : yarn build
6964
70- release :
65+ publish :
66+ if : " ${{!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'Release: Version Updates')}}"
7167 needs : [setup]
7268 runs-on : ubuntu-latest
69+ outputs :
70+ has_changes : ${{ steps.changes.outputs.has_changes }}
71+ permissions :
72+ contents : write # Required for git push and creating tags
73+ pull-requests : write # Required for creating pull requests
74+ id-token : write
7375 steps :
74- - uses : actions/checkout@v4
76+ - uses : actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
7577 with :
76- token : ${{ secrets.BOT_TOKEN }}
7778 fetch-depth : 0
78- ref : " master"
79+ ref : ' master'
80+ token : ${{ secrets.GITHUB_TOKEN }}
7981
8082 - name : Derive appropriate SHAs for base and head for `nx affected` commands
81- uses : nrwl/nx-set-shas@v3
83+ uses : nrwl/nx-set-shas@826660b82addbef3abff5fa871492ebad618c9e1 # v4.3.3
8284 with :
83- main-branch-name : " master"
85+ main-branch-name : ' master'
8486
8587 - name : Set Node Version
86- uses : actions/setup-node@v4
88+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
8789 with :
8890 node-version : 22
89- cache : " yarn"
90- cache-dependency-path : " yarn.lock"
91+ cache : ' yarn'
92+ cache-dependency-path : ' yarn.lock'
9193
92- # - name: Get yarn cache directory path
93- # id: yarn-cache-dir-path
94- # run: |
95- # echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
96-
97- # - name: Restore yarn cache
98- # uses: actions/cache@v3
99- # id: yarn-cache
100- # with:
101- # path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
102- # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
103- # restore-keys: |
104- # ${{ runner.os }}-yarn-
94+ - name : Install latest npm
95+ run : npm install -g npm@latest
10596
10697 - name : Install Dependencies
10798 run : yarn install --immutable
@@ -111,26 +102,81 @@ jobs:
111102
112103 - name : Setup Publish Config
113104 run : |
114- yarn config set npmAuthToken "${{ secrets.NPM_TOKEN }}"
115- git config --global user.email ${{ secrets.GH_EMAIL }}
116- git config --global user.name ${{ secrets.GH_USER }}
105+ git config user.email ${{ secrets.GH_EMAIL }}
106+ git config user.name ${{ secrets.GH_USER }}
117107
118- # TODO: ngx-deploy-npm? Or continue to leverage nx + yarn npm publish command?
119- - name : Publish
108+ - name : Store initial commit SHA
109+ id : initial-sha
110+ run : echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
111+
112+ - name : Version Packages
120113 run : |
121114 yarn nx affected --target version --parallel=1
115+
116+ - name : Check for Version Changes
117+ id : changes
118+ run : |
119+ INITIAL_SHA="${{ steps.initial-sha.outputs.sha }}"
120+ CURRENT_SHA=$(git rev-parse HEAD)
121+ if [ "$INITIAL_SHA" = "$CURRENT_SHA" ]; then
122+ echo "has_changes=false" >> $GITHUB_OUTPUT
123+ echo "No new commits created by version step"
124+ else
125+ echo "has_changes=true" >> $GITHUB_OUTPUT
126+ echo "New commits created by version step"
127+ fi
128+
129+ - name : Publish
130+ if : steps.changes.outputs.has_changes == 'true'
131+ run : |
122132 yarn nx affected --target publish --parallel=1
123- git push && git push --tags
133+
134+ - name : Create Release PR
135+ if : steps.changes.outputs.has_changes == 'true'
136+ env :
137+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
138+ run : |
139+ echo "Creating PR because changes detected: ${{ steps.changes.outputs.has_changes }}"
140+ git push origin --delete release/version-updates || true
141+ git checkout -b release/version-updates
142+ git push origin release/version-updates
143+ git push origin --tags
144+ gh pr create --title "Release: Version Updates" --body "Automated release PR with version updates and package publications." --base master --head release/version-updates
145+
146+ deploy-docs :
147+ if : " ${{!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'Release: Version Updates')}}"
148+ needs : [publish]
149+ runs-on : ubuntu-latest
150+ permissions :
151+ pages : write
152+ id-token : write
153+ environment :
154+ name : github-pages
155+ url : ${{ steps.deployment.outputs.page_url }}
156+ steps :
157+ - uses : actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
158+ with :
159+ fetch-depth : 0
160+ ref : ' master'
161+
162+ - name : Set Node Version
163+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
164+ with :
165+ node-version : 22
166+ cache : ' yarn'
167+ cache-dependency-path : ' yarn.lock'
168+
169+ - name : Install Dependencies
170+ run : yarn install --immutable
124171
125172 - name : Build Docs
126173 run : yarn build:docs
127174
128- - name : Deploy Docs
129- uses : crazy-max/ghaction-github- pages@v3
175+ - name : Upload Pages Artifact
176+ uses : actions/upload- pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
130177 with :
131- target_branch : gh-pages
132- build_dir : docusaurus/build
133- commit_message : deployed docs [skip ci]
134- committer : ${{ secrets.GH_USER }} ${{ secrets.GH_EMAIL }}
135- env :
136- GITHUB_TOKEN : ${{ secrets.BOT_TOKEN }}
178+ path : docusaurus/build
179+
180+ - name : Deploy to GitHub Pages
181+ id : deployment
182+ uses : actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
0 commit comments