-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (79 loc) · 2.8 KB
/
deploy_release.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
name: Deploy Release Build
# Trigger on new version tag
on:
push:
tags:
- '[0-9]+.[0-9]+*'
jobs:
build_deploy_to_registry:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# Enable docker cache to speed-up builds
- name: Setup Docker build cache
uses: actions/cache@v3
with:
path: /tmp/buildx-cache
key: ${{runner.os}}-buildx-${{github.sha}}
restore-keys: |
${{runner.os}}-buildx-
# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Docker login
uses: docker/login-action@v3
with:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_ACCESS_TOKEN}}
- name: Build + Push image (tag = git tag)
env:
# `github.ref_name` == git tag triggered build
IMAGE_VERSION: ${{github.ref_name}}
run: |
docker buildx build \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${IMAGE_VERSION}" \
--platform "linux/amd64,linux/arm/v7,linux/arm64" \
--pull \
--tag "${{secrets.REGISTRY_USERNAME}}/openconnect:${IMAGE_VERSION}" \
--output "type=image,push=true" \
--file ./Dockerfile .
- name: Build + Push image ("latest")
env:
# `github.ref_name` == git tag triggered build
IMAGE_VERSION: ${{github.ref_name}}
run: |
docker buildx build \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${IMAGE_VERSION}" \
--platform "linux/amd64,linux/arm/v7,linux/arm64" \
--tag "${{secrets.REGISTRY_USERNAME}}/openconnect:latest" \
--output "type=image,push=true" \
--file ./Dockerfile .
create_release:
runs-on: ubuntu-latest
permissions:
contents: write
needs: build_deploy_to_registry
steps:
- name: Create Github Release
uses: ncipollo/release-action@v1.13.0
with:
tag: ${{github.ref_name}}
name: ${{github.ref_name}}
body: (Automated release)
draft: false
prerelease: false
# Allow re-run workflow job
skipIfReleaseExists: true