@@ -2,7 +2,7 @@ name: dockerize-runtime-exporter
22
33on :
44 workflow_dispatch :
5- pull_request_target :
5+ pull_request :
66 branches : [main]
77 types : [opened, synchronize, reopened]
88 paths :
1111 - " !**/*.md"
1212 - " !services/runtime-exporter/package-lock.json"
1313 push :
14- branches :
15- - main
14+ branches : [main]
1615 paths :
1716 - " services/runtime-exporter/**"
1817 - " .github/workflows/dockerize-runtime-exporter.yml"
@@ -35,19 +34,25 @@ jobs:
3534 - uses : actions/checkout@v3
3635 with :
3736 fetch-depth : 0
38- ref : ${{ github.event.pull_request.head.ref }}
39- repository : ${{ github.event.pull_request.head.repo.full_name }}
37+
38+ - name : Cache node modules
39+ id : cache-node-modules
40+ uses : actions/cache@v3
41+ with :
42+ path : services/runtime-exporter/node_modules
43+ key : ${{ runner.os }}-node-${{ hashFiles('services/runtime-exporter/package-lock.json') }}
4044
4145 - name : Use Node
4246 uses : actions/setup-node@v3
4347 with :
44- node-version : 20 .x
48+ node-version : 18 .x
4549
4650 - name : Install Package
4751 working-directory : services/runtime-exporter
48- run : npm cache clean --force && npm install
52+ if : steps.cache-node-modules.outputs.cache-hit != 'true'
53+ run : npm ci
4954
50- - name : Build Packages
55+ - name : Build runtime-exporter
5156 working-directory : services/runtime-exporter
5257 run : npm run build
5358
@@ -56,14 +61,14 @@ jobs:
5661 uses : docker/metadata-action@v4
5762 with :
5863 images : |
59- ghcr.io/${{ github.repository_owner }}/runtime-exporter
60- docker.io/${{ secrets.DOCKER_USERNAME }}/runtime-exporter
64+ ghcr.io/${{ github.repository_owner }}/laf- runtime-exporter
65+ docker.io/${{ secrets.DOCKER_USERNAME }}/laf- runtime-exporter
6166 # https://github.com/docker/metadata-action#typesemver
6267 tags : |
6368 type=ref,event=pr
64- type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target ' }}
65- type=sha,format=short,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target ' }}
66- type=raw,value={{branch}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') && !startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request_target ' }}
69+ type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request ' }}
70+ type=sha,format=short,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request ' }}
71+ type=raw,value={{branch}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') && !startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request ' }}
6772
6873 - name : Set up QEMU
6974 uses : docker/setup-qemu-action@v2
@@ -72,12 +77,14 @@ jobs:
7277 uses : docker/setup-buildx-action@v2
7378
7479 - name : Login to DockerHub
80+ if : github.event_name != 'pull_request'
7581 uses : docker/login-action@v2
7682 with :
7783 username : ${{ secrets.DOCKER_USERNAME }}
7884 password : ${{ secrets.DOCKER_PASSWORD }}
7985
8086 - name : Login to Github Container Hub
87+ if : github.event_name != 'pull_request'
8188 uses : docker/login-action@v2
8289 with :
8390 registry : ghcr.io
@@ -90,27 +97,26 @@ jobs:
9097 with :
9198 context : ./services/runtime-exporter
9299 file : ./services/runtime-exporter/Dockerfile
93- push : true
100+ push : ${{ github.event_name != 'pull_request' }}
94101 tags : ${{ steps.meta.outputs.tags }}
95102 labels : ${{ steps.meta.outputs.labels }}
96103 platforms : linux/amd64, linux/arm64
97104
98105 - name : Comment docker image tags to PR
99- if : github.event_name == 'pull_request_target '
106+ if : github.event_name == 'pull_request '
100107 uses : mshick/add-pr-comment@v2
101108 with :
102109 message-id : " dockerize-runtime-exporter"
103110 message : |
104- **:boom: laf runtime exporter image built successfully for pr ${{ github.event.pull_request.number }}**
111+ **:boom: laf runtime- exporter built successfully for pr ${{ github.event.pull_request.number }}**
105112 ```
106- ${{ steps.meta.outputs.tags }}
113+ Docker image built (not pushed in PR)
107114 ```
108- digest: `${{ steps.docker-build.outputs.digest }}`
109115
110116 trigger-workflow-build-cluster-image :
111117 needs : [dockerize-runtime-exporter]
118+ if : github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request'
112119 runs-on : ubuntu-latest
113- if : github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target'
114120 steps :
115121 - name : trigger cluster image workflow
116122 uses : peter-evans/repository-dispatch@v2
0 commit comments