forked from RossBugginsNHS/github-workflow-dispatcher
-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (68 loc) · 2.54 KB
/
publish-devcontainer.yml
File metadata and controls
78 lines (68 loc) · 2.54 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
name: Publish Dev Container
on:
push:
branches: [main]
paths:
- .devcontainer/Dockerfile
- mise.toml
- mise.lock
tags:
- "devcontainer/v*"
pull_request:
paths:
- .devcontainer/Dockerfile
- mise.toml
- mise.lock
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Build and Publish Dev Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set image name
# Image is always lowercased; GitHub Container Registry requires lowercase names.
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "IMAGE_NAME=ghcr.io/${REPO_LOWER}/devcontainer" >> "$GITHUB_ENV"
- name: Set up QEMU (for multi-platform builds)
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract image metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=match,pattern=devcontainer/v(\d+\.\d+\.\d+),group=1
type=match,pattern=devcontainer/v(\d+\.\d+),group=1
type=sha,prefix=sha-,format=short
- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .devcontainer
file: .devcontainer/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/devcontainer/')) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false