-
Notifications
You must be signed in to change notification settings - Fork 16
90 lines (80 loc) · 3.21 KB
/
docker-publish.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
name: Publish Console Image to Docker Hub
on:
push:
branches: [ "main" ]
tags:
# Publish semver tags as releases.
- app-ziti-console-v*.*.*
env:
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ vars.ZITI_CONSOLE_IMAGE_NAME || 'openziti/ziti-console-assets' }}
# oldest, supported, compatible LTS (even numbered Node versions); defines the source image version used to build the
# ziti-console container image
NODE_VERSION: 20
jobs:
docker-build-push:
name: Push SPA Image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
id-token: write
attestations: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY}}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY}}
username: ${{ vars.DOCKER_HUB_API_USER || secrets.DOCKER_HUB_API_USER }}
password: ${{ secrets.DOCKER_HUB_API_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Define Docker Tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}
tags: |
# set "main" tag on revisions that are accepted into the default branch
type=raw,value=${{ github.ref_name }},enable={{is_default_branch}}
# set "latest" tag on releases
type=raw,value=latest,enable=${{startsWith(github.ref_name, 'app-ziti-console-v')}}
# set (e.g., "1.2.3") semver tag on releases
type=match,pattern=app-ziti-console-v(.*),group=1,enable=${{startsWith(github.ref_name, 'app-ziti-console-v')}}
# set (e.g., "v1") major version tag on releases
type=match,pattern=app-ziti-console-(v\d+)\..*,group=1,enable=${{startsWith(github.ref_name, 'app-ziti-console-v')}}
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64
- name: Set Up Docker BuildKit
id: buildx
uses: docker/setup-buildx-action@v3
# Build and push Docker image with Buildx
- name: Build and Push Docker Image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: ./docker-images/ziti-console-assets/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
# ziti controller always binds at /zac and trailing slash is necessary to qualify Angular runtime paths in index.html
build-args: |
NODE_VERSION=${{ env.NODE_VERSION }}
BASE_HREF=/zac/
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY}}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true