-
Notifications
You must be signed in to change notification settings - Fork 192
130 lines (130 loc) · 5.2 KB
/
publish_images.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
name: Publish images
on:
workflow_run:
workflows: ["Build and test"]
types: [completed]
branches: [develop]
env:
REGISTRY: ghcr.io
XROAD_HOME: ${{ github.workspace }}
jobs:
PublishCS:
name: Publish Central Server image
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Initialize docker setup
working-directory: ${{ github.workspace }}/Docker/centralserver
run: ./init_context.sh
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
- name: Download Debian packages
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "debian-packages"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/debian-packages.zip`, Buffer.from(download.data));
- name: Unzip Debian packages
run: mkdir -p ${{ github.workspace }}/Docker/centralserver/build/packages && unzip -d ${{ github.workspace }}/Docker/centralserver/build/packages debian-packages.zip
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ${{ github.workspace }}/Docker/centralserver
build-args: |
PACKAGE_SOURCE=internal
push: true
tags: ghcr.io/nordic-institute/xrddev-central-server:latest
- name: Clean old CS images
uses: snok/container-retention-policy@v2
with:
image-names: xrddev-central-server
cut-off: 1 week ago UTC
timestamp-to-use: created_at
account-type: org
org-name: nordic-institute
keep-at-least: 1
token-type: github-token
token: ${{ secrets.GITHUB_TOKEN }}
PublishSS:
name: Publish Security Server image
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Initialize docker setup
working-directory: ${{ github.workspace }}/Docker/securityserver
run: ./init_context.sh
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
- name: Download Debian packages
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "debian-packages"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/debian-packages.zip`, Buffer.from(download.data));
- name: Unzip Debian packages
run: mkdir -p ${{ github.workspace }}/Docker/securityserver/build/packages && unzip -d ${{ github.workspace }}/Docker/securityserver/build/packages debian-packages.zip
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ${{ github.workspace }}/Docker/securityserver
build-args: |
PACKAGE_SOURCE=internal
push: true
tags: ghcr.io/nordic-institute/xrddev-security-server:latest
- name: Clean old SS images
uses: snok/container-retention-policy@v2
with:
image-names: xrddev-security-server
cut-off: 1 week ago UTC
timestamp-to-use: created_at
account-type: org
org-name: nordic-institute
keep-at-least: 1
token-type: github-token
token: ${{ secrets.GITHUB_TOKEN }}