forked from eclipse-iofog/Controller
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (142 loc) · 4.07 KB
/
ci.yaml
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
name: CI
on:
push:
branches:
- main
tags: [v*]
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
pull_request:
# Sequence of patterns matched against refs/heads
branches:
- main
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
env:
IMAGE_NAME: 'controller'
jobs:
Build:
runs-on: ubuntu-22.04
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
name: Preflight
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Replace values
shell: bash
env:
PAT: ${{ secrets.PAT }}
run: |
sed -i.back "s|PAT|${PAT}|g" .npmrc
- run: npm config set @datasance:registry https://npm.pkg.github.com/
- run: npm install --build-from-source --force
- run: npm run standard
- run: |
npm i -g better-npm-audit
npx better-npm-audit audit -p
Publish:
needs: [Build]
runs-on: ubuntu-22.04
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
name: Publish Controller
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Replace values
shell: bash
env:
PAT: ${{ secrets.PAT }}
run: |
sed -i.back "s|PAT|${PAT}|g" .npmrc
- run: npm config set @datasance:registry https://npm.pkg.github.com/
- run: npm install --build-from-source --force
- name: npm version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: package version
shell: bash
id: version
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
echo "pkg_version=${{ steps.package-version.outputs.current-version}}" >> "${GITHUB_OUTPUT}"
else
echo "pkg_version=${{ steps.package-version.outputs.current-version}}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- name: npm pack with version from package version
run: |
npm pack
npm publish --registry=https://npm.pkg.github.com/
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.0
- name: Set image tag
shell: bash
id: tags
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
VERSION=${{ github.ref_name }}
echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}"
else
VERSION=${{ steps.previoustag.outputs.tag }}
echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.PAT }}
- name: Build and Push to ghcr
uses: docker/build-push-action@v3
id: build_push_ghcr
with:
file: Dockerfile.dev
context: .
platforms: linux/amd64, linux/arm64
push: true
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Controller
build-args: GITHUB_TOKEN=${{ secrets.PAT }}
tags: |
ghcr.io/datasance/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
ghcr.io/datasance/${{ env.IMAGE_NAME }}:latest
ghcr.io/datasance/${{ env.IMAGE_NAME }}:main