-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (89 loc) · 3.32 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
name: ci
on:
push:
branches:
- main
paths:
- .github/workflows/ci.yaml
- apps/**/*.go
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
app: ["hello-world"]
concurrency:
group: ci
cancel-in-progress: false
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 1
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Install melange
uses: chainguard-dev/actions/setup-melange@main
- name: Install cosign
uses: sigstore/[email protected]
with:
cosign-release: "v2.2.4"
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ${{ secrets.DOCKER_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Generate temporary signing key
uses: chainguard-dev/actions/melange-keygen@main
with:
signing-key-path: ${{ github.workspace }}/melange.rsa
- name: Build and package app
uses: chainguard-dev/actions/melange-build-pkg@main
with:
workdir: apps/${{ matrix.app }}
config: ${{ github.workspace }}/apps/${{ matrix.app }}/melange.yaml
archs: x86_64,aarch64
repository-path: ${{ github.workspace }}/packages
sign-with-key: true
signing-key-path: ${{ github.workspace }}/melange.rsa
- id: apko
name: Construct OCI image and publish
uses: distroless/actions/apko-publish@main
with:
apko-image: ghcr.io/wolfi-dev/apko:latest
config: ${{ github.workspace }}/apps/${{ matrix.app }}/apko.yaml
keyring-append: ${{ github.workspace }}/melange.rsa.pub
tag: ${{ secrets.DOCKER_REGISTRY_URL }}/${{ github.repository }}/${{ matrix.app }}:${{ steps.vars.outputs.sha_short }}
generic-user: ${{ secrets.DOCKER_REGISTRY_USER }}
generic-pass: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Sign the images with GitHub OIDC Token
run: |
cosign sign --yes ${{ steps.apko.outputs.digest }}
bump-version:
runs-on: ubuntu-latest
needs: build-and-push
permissions:
contents: write
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Bump version
run: |
sed -i 's|image: harbor.apko.do-2021.fr/do4-2022/openstack-k0s-apko/hello-world:[^ ]*|image: harbor.apko.do-2021.fr/do4-2022/openstack-k0s-apko/hello-world:${{ steps.vars.outputs.sha_short }}|' apps/hello-world/manifests/deployment.yaml
- name: Commit version bump
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "build: bump release image to ${{ steps.vars.outputs.sha_short }}"
commit_options: "-a --no-verify --signoff"
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>