11name : CI
22on :
3- push :
3+ push :
44 branches :
5- - develop
6- - release*
5+ - main
76 tags : [v*]
87 paths-ignore :
98 - README.md
109 - CHANGELOG.md
1110 - LICENSE
1211 pull_request :
13- # Sequence of patterns matched against refs/heads
14- branches :
15- - develop
16- - release*
12+ # Sequence of patterns matched against refs/heads
13+ branches :
14+ - main
1715 paths-ignore :
1816 - README.md
1917 - CHANGELOG.md
2018 - LICENSE
21-
2219env :
23- project : ' focal-freedom-236620 '
24- image : ' controller '
20+ IMAGE_NAME : ' controller '
21+
2522
2623
2724jobs :
2825 Build :
29- runs-on : ubuntu-latest
26+ runs-on : ubuntu-22.04
3027 permissions :
31- contents : ' read'
32- id-token : ' write'
33- packages : ' write'
28+ actions : write
29+ checks : write
30+ contents : write
31+ deployments : write
32+ id-token : write
33+ issues : write
34+ discussions : write
35+ packages : write
36+ pages : write
37+ pull-requests : write
38+ repository-projects : write
39+ security-events : write
40+ statuses : write
3441 name : Preflight
3542 steps :
36- - uses : actions/checkout@v3
37- - uses : actions/setup-node@v3
43+ - uses : actions/checkout@v4
44+ - uses : actions/setup-node@v4
3845 with :
39- node-version : 18
40- - run : npm ci
46+ node-version : 24
47+ - name : Replace values
48+ shell : bash
49+ env :
50+ PAT : ${{ secrets.GITHUB_TOKEN }}
51+ run : |
52+ sed -i.back "s|PAT|${GITHUB_TOKEN}|g" .npmrc
53+ - run : npm config set @eclipse-iofog:registry https://npm.pkg.github.com/
54+ - run : npm install --build-from-source --force
4155 - run : npm run standard
4256 - run : |
4357 npm i -g better-npm-audit
4458 npx better-npm-audit audit -p
4559
46- Tests :
47- needs : Build
48- runs-on : ubuntu-latest
60+ Publish :
61+ needs : [ Build]
62+ runs-on : ubuntu-22.04
4963 permissions :
50- contents : ' read'
51- id-token : ' write'
52- packages : ' write'
53- issues : read
64+ actions : write
5465 checks : write
66+ contents : write
67+ deployments : write
68+ id-token : write
69+ issues : write
70+ discussions : write
71+ packages : write
72+ pages : write
5573 pull-requests : write
56- strategy :
57- matrix :
58- node : [ 16, 17, 16, 19 ]
59- name : Node ${{ matrix.node }} Test
60- steps :
61- - uses : actions/checkout@v3
62- - name : Setup Node ${{ matrix.node }} Test
63- uses : actions/setup-node@v3
64- with :
65- node-version : ${{ matrix.node }}
66- - name : Cache Node Modules
67- uses : actions/cache@v3
68- with :
69- path : |
70- node_modules
71- key : ${{ runner.os }}-controller-node_modules-${{ hashFiles('package-lock.json') }}
72- restore-keys : |
73- ${{ runner.os }}-controller-node_modules-
74- - run : npm ci
75- - run : npm run test -- junit
76- - run : npm run postman_test
77- - name : Publish Test Results
78- uses : EnricoMi/publish-unit-test-result-action@v2
79- if : always()
80- with :
81- files : |
82- *-results.xml
83-
84- Publish :
85- needs : [Build, Tests]
86- runs-on : ubuntu-latest
87- permissions :
88- contents : ' read'
89- id-token : ' write'
90- packages : ' write'
74+ repository-projects : write
75+ security-events : write
76+ statuses : write
9177 name : Publish Controller
9278 steps :
93- - uses : actions/checkout@v3
94- - uses : actions/setup-node@v3
79+ - uses : actions/checkout@v4
80+ - uses : actions/setup-node@v4
9581 with :
96- node-version : 18
97- - run : npm ci
82+ node-version : 24
83+ - name : Replace values
84+ shell : bash
85+ env :
86+ PAT : ${{ secrets.GITHUB_TOKEN }}
87+ run : |
88+ sed -i.back "s|PAT|${PAT}|g" .npmrc
89+ - run : npm config set @eclipse-iofog:registry https://npm.pkg.github.com/
90+ - run : npm install --build-from-source --force
9891
9992 - name : npm version
10093 id : package-version
@@ -112,47 +105,51 @@ jobs:
112105
113106 - name : npm pack with version from package version
114107 run : |
115- npm --no-git-tag-version version ${{ steps.version.outputs.pkg_version }}
116108 npm pack
109+ npm publish --registry=https://npm.pkg.github.com/
110+
111+ - name : ' Get Previous tag'
112+ id : previoustag
113+ uses : " WyriHaximus/github-action-get-previous-tag@v1"
114+ with :
115+ fallback : 0.0.0
116+ - name : Set image tag
117+ shell : bash
118+ id : tags
119+ run : |
120+ if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
121+ VERSION=${{ github.ref_name }}
122+ echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}"
123+ else
124+ VERSION=${{ steps.previoustag.outputs.tag }}
125+ echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
126+ fi
127+
128+ - name : Set up QEMU
129+ uses : docker/setup-qemu-action@v3
130+ - name : Set up Docker Buildx
131+ uses : docker/setup-buildx-action@v3
132+ with :
133+ version : v0.29.1
134+
117135
118136 - name : Login to Github Container Registry
119137 uses : docker/login-action@v2
120138 with :
121139 registry : " ghcr.io"
122140 username : ${{ github.actor }}
123- password : ${{ github.token }}
124-
141+ password : ${{ secrets.GITHUB_TOKEN }}
142+
125143 - name : Build and Push to ghcr
126144 uses : docker/build-push-action@v3
127145 id : build_push_ghcr
128146 with :
129- file : Dockerfile.dev
147+ file : Dockerfile
148+ context : .
149+ platforms : linux/amd64, linux/arm64
130150 push : true
151+ outputs : type=image,name=target,annotation-index.org.opencontainers.image.description=Controller
131152 tags : |
132- ghcr.io/eclipse-iofog/controller:${{ steps.version.outputs.pkg_version }}
133- ghcr.io/eclipse-iofog/controller:latest
134- build-args : PKG_VERSION=${{ steps.version.outputs.pkg_version }}
135-
136- - name : Build and Push to GCR
137- id : build_push_gcr
138- uses : RafikFarhad/push-to-gcr-github-action@v5-beta
139- with :
140- gcloud_service_key : ${{ secrets.GCLOUD_SERVICE_KEY }}
141- registry : gcr.io
142- project_id : ${{ env.project }}
143- image_name : ${{ env.image }}
144- image_tag : latest,${{ steps.version.outputs.pkg_version }}
145- dockerfile : Dockerfile.dev
146- build_args : PKG_VERSION=${{ steps.version.outputs.pkg_version }}
147-
148- - run : ls
149-
150- - name : Publish package to packagecloud
151- if : ${{ steps.build_push_gcr.outcome }} == 'success'
152- uses : danielmundi/upload-packagecloud@v1
153- with :
154- PACKAGE-NAME : iofog-iofogcontroller-${{ steps.version.outputs.pkg_version }}.tgz
155- PACKAGECLOUD-USERNAME : iofog
156- PACKAGECLOUD-REPO : iofog-controller-snapshots
157- PACKAGECLOUD-DISTRIB : node
158- PACKAGECLOUD-TOKEN : ${{ secrets.packagecloud_token }}
153+ ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
154+ ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:latest
155+ ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:main
0 commit comments