-
Notifications
You must be signed in to change notification settings - Fork 7
81 lines (69 loc) · 3.33 KB
/
publish.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
name: image publish
run-name: Publish ROCK image from ${{ inputs.rock }} to ghcr.io/canonical/identity-platform-login-ui
on:
workflow_call:
inputs:
rock:
type: string
required: true
description: "rock path to download"
outputs:
image:
description: "container image"
value: ${{ jobs.publish.outputs.image }}
jobs:
publish:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.set.outputs.image }}
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Download Artifact
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: ${{ inputs.rock }}
# Use the rockcraft snap to get skopeo because the snap and the apt package on the ubuntu
# archives are very old. Only rockcraft=latest/edge has a newer skopeo version
# TODO: Either use rockcraft=latest/stable or install skopeo from apt when one
# of them is updated
- name: Install Rockcraft to get Skopeo
run: sudo snap install --classic --channel latest/edge rockcraft
- name: Install Skaffold and Container Structure Tests tools
run: |
mkdir -p bin/
curl -Lo bin/container-structure-test https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64
chmod +x bin/container-structure-test
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Run container structural tests
run: |
# docker-daemon avoids the push to the remote registry
sudo rockcraft.skopeo --insecure-policy copy oci-archive:$(realpath ./"${{ inputs.rock }}") docker-daemon:ghcr.io/canonical/identity-platform-login-ui:${{ github.sha }} --dest-creds ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}
container-structure-test test -c structure-tests.yaml -i ghcr.io/canonical/identity-platform-login-ui:${{ github.sha }}
- name: Upload ROCK to ghcr.io in latest channel
id: latest
if: ${{ github.ref_type }} == "branch"
run: |
versions=(latest "${{ github.sha }}")
for version in "${versions[@]}"; do
sudo rockcraft.skopeo --insecure-policy copy \
--dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
oci-archive:$(realpath ./"${{ inputs.rock }}") \
docker://ghcr.io/canonical/identity-platform-login-ui:"${version}"
done
echo "image=ghcr.io/canonical/identity-platform-login-ui:${{ github.sha }}" >> "$GITHUB_ENV"
- name: Upload ROCK to ghcr.io in stable channel
id: stable
if: ${{ github.ref_type }} == "tag"
run: |
versions=(stable "${{ github.ref_name }}")
for version in "${versions[@]}"; do
sudo rockcraft.skopeo --insecure-policy copy \
--dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
oci-archive:$(realpath ./"${{ inputs.rock }}") \
docker://ghcr.io/canonical/identity-platform-login-ui:"${version}"
done
echo "image=ghcr.io/canonical/identity-platform-login-ui:${{ github.ref_name }}" >> "$GITHUB_ENV"
- name: Set output of image
id: set
run: echo "image=$image" >> "$GITHUB_OUTPUT"