@@ -31,14 +31,14 @@ jobs:
3131 - uses : actions/checkout@v2
3232 with :
3333 fetch-depth : 0
34- persist-credentials : false
3534 token : ${{ secrets.GH_TOKEN }}
3635
3736 # We initialize the node action
3837 - name : Use node.js ${{ matrix.node }}
39- uses : actions/setup-node@v1
38+ uses : actions/setup-node@v2
4039 with :
4140 node-version : ${{ matrix.node }}
41+ cache : ' npm'
4242 registry-url : https://npm.pkg.github.com
4343
4444 # We install our dependencies
@@ -60,43 +60,15 @@ jobs:
6060 # We build our code base
6161 - name : Configure git
6262 run : |
63- git config --local user.name 'tractr-bot'
64- git config --local user.email '[email protected] ' 63+ git config user.name 'tractr-bot'
64+ git config user.email '[email protected] ' 6565
6666 # We run our release script
6767 - name : nx run workspace:release
6868 env :
69+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
6970 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
70- run : npx nx run workspace:release --base latest
71-
72- - name : Push changes
73- uses : ad-m/github-push-action@master
74- with :
75- github_token : ${{ secrets.GH_TOKEN }}
76- branch : ${{ github.ref }}
77- tags : true
78-
79- # Set the matrix apps that have been affected by all the changes
80- - name : Affected apps output
81- id : nx-apps
82- run : |
83- echo "::set-output name=apps::$(npx nx affected:apps --plain --base latest | sed 's/ /,/g')"
84-
85- - name : Return formatted output
86- uses : actions/github-script@v3
87- id : apps
88- env :
89- APPS : ${{ steps.nx-apps.outputs.apps }}
90- with :
91- script : |
92- const fs = require('fs');
93- const join = require('path').join;
94- const apps = process.env.APPS.split(',')
95- .filter((name) => name !== '')
96- .filter((name) => fs.existsSync(join(process.cwd(), 'apps', name, 'Dockerfile')));
97-
98- console.log('Set the matrix to deploy the docker container:', apps);
99- return apps;
71+ run : npx nx run workspace:release --base latest --push
10072
10173 - name : Get the last commit SHA
10274 id : commit
11082 SHA : ${{ steps.commit.outputs.sha }}
11183
11284 with :
113- github-token : ${{secrets.GITHUB_TOKEN }}
85+ github-token : ${{secrets.GH_TOKEN }}
11486 script : |
11587 try {
11688 console.log("Remove the latest tag from the repository")
@@ -129,104 +101,3 @@ jobs:
129101 ref: "refs/tags/latest",
130102 sha: process.env.SHA
131103 })
132-
133- docker-release :
134- # If we got some change inside apps/** we execute this job
135- if : |
136- !contains(github.event.commits[0].message, 'chore(release):') &&
137- !failure() &&
138- !contains(needs.npm-changes.outputs.apps, '[]')
139- needs : [npm-release]
140- strategy :
141- matrix :
142- app : ${{ fromJSON(needs.npm-release.outputs.apps) }}
143- node : [16.x]
144- os : [ubuntu-20.04]
145- scope : [tractr]
146- repository : [tractr]
147- name : docker release ${{ matrix.app }} (@${{ matrix.scope }})
148- runs-on : ['${{ matrix.os }}']
149- steps :
150- # Checkout the source code
151- - uses : actions/checkout@v2
152-
153- # Setup the node js env
154- - name : use node.js ${{ matrix.node }}
155- uses : actions/setup-node@v1
156- with :
157- node-version : ${{ matrix.node }}
158- registry-url : https://npm.pkg.github.com
159-
160- # Get some cache to speed up docker build
161- - name : Cache Docker layers
162- uses : actions/cache@v2
163- with :
164- path : /tmp/.buildx-cache
165- key : ${{ runner.os }}-buildx-${{ matrix.app }}-${{ github.sha }}
166- restore-keys : |
167- ${{ runner.os }}-buildx-${{ matrix.app }}-
168-
169- - name : Extract version
170- id : extract_version
171- 172- with :
173- path : ./apps/${{ matrix.app }}
174-
175- # Register some meta data to build docker
176- - name : Docker meta
177- id : docker_meta
178- uses : docker/metadata-action@v3
179- with :
180- flavor : |
181- latest=true
182- tags : |
183- type=ref,event=branch
184- type=semver,pattern={{version}},value=v${{ steps.extract_version.outputs.version }}
185- type=semver,pattern={{major}}.{{minor}},value=v${{ steps.extract_version.outputs.version }}
186- images :
187- ghcr.io/${{ matrix.repository }}/${{ matrix.scope }}-${{ matrix.app
188- }}
189-
190- # Setup QEMU
191- - name : Set up QEMU
192- uses : docker/setup-qemu-action@v1
193-
194- # RSetup buildx
195- - uses : docker/setup-buildx-action@v1
196- id : buildx
197- with :
198- install : true
199-
200- # Loggin to our docker registry
201- - name : Login to GitHub Container Registry
202- uses : docker/login-action@v1
203- with :
204- registry : ghcr.io
205- username : ${{ github.repository_owner }}
206- password : ${{ secrets.GH_TOKEN }}
207-
208- # Build and push our docker images to the registry
209- - name : Build and push
210- id : docker_build
211- uses : docker/build-push-action@v2
212- with :
213- context : .
214- push : true
215- file : ./apps/${{ matrix.app }}/Dockerfile
216- secret-files : npmrc=${{ env.NPM_CONFIG_USERCONFIG }}
217- tags : ${{ steps.docker_meta.outputs.tags }}
218- labels : ${{ steps.docker_meta.outputs.labels }}
219- cache-from : type=local,src=/tmp/.buildx-cache
220- cache-to : type=local,dest=/tmp/.buildx-cache-new
221- build-args : |
222- app=${{ matrix.app }}
223- NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}
224-
225- # Temp fix
226- # https://github.com/docker/build-push-action/issues/252
227- # https://github.com/moby/buildkit/issues/1896
228- # Change the cache for buildx
229- - name : Move cache
230- run : |
231- rm -rf /tmp/.buildx-cache
232- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
0 commit comments