Skip to content

Commit 80da3e1

Browse files
authored
Merge pull request #84 from smithclay/feature/publish-to-ghcr
Adds workflow for publishing image to the repo's ghcr.io repository
2 parents 524f434 + 1b7f11f commit 80da3e1

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish Devcontainer to GHCR
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- '.devcontainer/Dockerfile'
8+
- '.github/workflows/publish-devcontainer.yml'
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}/devcontainer
14+
15+
jobs:
16+
publish-devcontainer:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
- name: Log in to Container Registry
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Extract metadata
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
tags: |
39+
type=ref,event=branch
40+
type=sha,prefix={{branch}}-
41+
type=raw,value=latest,enable={{is_default_branch}}
42+
- name: Build and push devcontainer image
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
file: .devcontainer/Dockerfile
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)