-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (80 loc) · 2.67 KB
/
publish.yml
File metadata and controls
95 lines (80 loc) · 2.67 KB
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
name: Publish Image and Helm Chart
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request: {}
permissions:
contents: read
packages: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/open-craft/pr-sandbox-automation
tags: |
type=sha,format=short,prefix=sha-
type=ref,event=tag
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Set chart versions
id: chart
run: |
set -euo pipefail
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
version="${GITHUB_REF_NAME#v}"
app_version="${GITHUB_REF_NAME#v}"
else
short_sha="$(git rev-parse --short=8 HEAD)"
version="0.1.0-sha.${short_sha}"
app_version="sha-${short_sha}"
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
echo "app_version=${app_version}" >> "${GITHUB_OUTPUT}"
- name: Set up Helm
uses: azure/setup-helm@v4
- name: Helm dependency update
run: helm dependency update charts/pr-sandbox-automation
- name: Helm lint
run: helm lint charts/pr-sandbox-automation
- name: Helm package
if: github.event_name != 'pull_request'
run: |
helm package charts/pr-sandbox-automation \
--version "${{ steps.chart.outputs.version }}" \
--app-version "${{ steps.chart.outputs.app_version }}"
- name: Helm registry login
if: github.event_name != 'pull_request'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io \
-u "${{ github.actor }}" --password-stdin
- name: Helm push
if: github.event_name != 'pull_request'
run: |
helm push "pr-sandbox-automation-${{ steps.chart.outputs.version }}.tgz" \
oci://ghcr.io/open-craft/charts