-
Notifications
You must be signed in to change notification settings - Fork 2
131 lines (115 loc) · 5.14 KB
/
ci.yml
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
---
name: Build, Release, and Sign Docker Images
on:
pull_request:
branches:
- main
types:
- closed
jobs:
build_and_push:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
outputs:
version: ${{ steps.semantic_release.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create and Push Tag
id: create_tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: main
default_bump: minor
create_annotated_tag: true
- name: Print the new tags
run: |
echo "TAG: ${{ steps.create_tag.outputs.new_tag }}"
VERSION=$(echo ${{ steps.create_tag.outputs.new_tag }} | sed 's/^v//')
echo "VERSION: $VERSION"
- name: Install cosign
uses: sigstore/[email protected]
with:
cosign-release: 'v2.2.3'
- name: Confirm cosign installation
run: cosign version
- name: Log in to Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push SHIDAI Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./shidai.Dockerfile
push: true
tags: ghcr.io/kiracore/sekin/shidai:${{ steps.create_tag.outputs.new_tag }}
labels:
org.opencontainers.image.authors="kira.network"
org.opencontainers.image.url="https://github.com/KiraCore/sekin"
org.opencontainers.image.documentation="https://github.com/KiraCore/sekin/blob/main/README.md"
org.opencontainers.image.source="https://github.com/KiraCore/sekin.git"
org.opencontainers.image.vendor="KIRA"
org.opencontainers.image.licenses="CC BY-NC-SA 4.0."
org.opencontainers.image.title="SHIDAI"
org.opencontainers.image.description="Infra manager"
- name: Retrieve SHIDAI image digest
id: get-shidai-digest
run: |
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/kiracore/sekin/shidai:${{ steps.create_tag.outputs.new_tag }})
echo "Digest: $DIGEST"
echo "::set-output name=digest::$DIGEST"
- name: Sign published SHIDAI Docker image with digest
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
run: |
echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key
cosign sign --key cosign.key ${{ steps.get-shidai-digest.outputs.digest }} --yes
dd if=/dev/zero of=cosign.key bs=1 count=$(stat --format=%s cosign.key)
rm -f cosign.key
- name: Build and push SYSLOG-NG Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./syslog-ng.Dockerfile
push: true
tags: ghcr.io/kiracore/sekin/syslog-ng:${{ steps.create_tag.outputs.new_tag }}
labels:
org.opencontainers.image.authors="kira.network"
org.opencontainers.image.url="https://github.com/KiraCore/sekin"
org.opencontainers.image.documentation="https://github.com/KiraCore/sekin/blob/main/README.md"
org.opencontainers.image.source="https://github.com/KiraCore/sekin.git"
org.opencontainers.image.vendor="KIRA"
org.opencontainers.image.licenses="CC BY-NC-SA 4.0."
org.opencontainers.image.title="syslog-ng"
org.opencontainers.image.description="Log server"
- name: Retrieve SYSLOG-NG image digest
id: get-syslog-digest
run: |
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/kiracore/sekin/syslog-ng:${{ steps.create_tag.outputs.new_tag }})
echo "Digest: $DIGEST"
echo "::set-output name=digest::$DIGEST"
- name: Sign published SYSLOG-NG Docker image with digest
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
run: |
echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key
cosign sign --key cosign.key ${{ steps.get-syslog-digest.outputs.digest }} --yes
dd if=/dev/zero of=cosign.key bs=1 count=$(stat --format=%s cosign.key)
rm -f cosign.key
- name: Update image version in compose.yml
run: |
sed -i "s/syslog-ng:v[0-9]*\.[0-9]*\.[0-9]*/syslog-ng:${{ steps.create_tag.outputs.new_tag }}/g" compose.yml
sed -i "s/shidai:v[0-9]*\.[0-9]*\.[0-9]*/shidai:${{ steps.create_tag.outputs.new_tag }}/g" compose.yml
- name: Commit and push updated compose.yml
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add compose.yml
git commit -m "fix(cidi_auto): Update compose.yml" \
-m "Update image versions to ${{ steps.create_tag.outputs.new_tag }}"
git tag -a ${{ steps.create_tag.outputs.new_tag }} -m "Update image versions to ${{ steps.create_tag.outputs.new_tag }}"
git push