-
Notifications
You must be signed in to change notification settings - Fork 3
77 lines (68 loc) · 2.21 KB
/
build-dev-image.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
name: Build Dev Container Base Image
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
workflow_dispatch: # Manually triggered
env:
CONTAINER_REGISTRY: ghcr.io
IMAGE_NAME: access-system-dev
BRANCH_NAME: ${{ github.head_ref || github.ref }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 🧰 Get branch name
run: | # Get the branch name from the ref and replace non-alphanumeric characters with hyphens
BRANCH=$(echo "${BRANCH_NAME#refs/heads/}" | sed -e 's/[^a-zA-Z0-9]/-/g')
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: 🏷️ Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.CONTAINER_REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,priority=610
type=ref,event=pr
type=semver,pattern={{raw}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=v{{major}}
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{ env.BRANCH_NAME }},priority=10
annotations: |
runnumber=${{ github.run_id }}
sha=${{ github.sha }}
ref=${{ github.ref }}
- name: 🔐 Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🚀 Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: .devcontainer/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max