-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (65 loc) · 2.22 KB
/
build-devcontainer.yaml
File metadata and controls
78 lines (65 loc) · 2.22 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: Devcontainer Image Build
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths: [".devcontainer/Dockerfile"]
pull_request:
branches: [ "main" ]
paths: [".devcontainer/Dockerfile"]
jobs:
build_parameters:
name: Define Build Parameters
runs-on: ubuntu-22.04
# We need to share details across job boundaries, expose the step outputs at the job level
outputs:
container_owner: ${{ steps.build_params.outputs.container_owner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Define Build Parameters
id: build_params
uses: actions/github-script@v7
with:
script: |
const containerOwner = `${context.repo.owner}`.toLowerCase() + `/${context.repo.repo}`.toLowerCase();
core.setOutput('container_owner', containerOwner);
build:
runs-on: ubuntu-latest
needs:
- build_parameters
steps:
- uses: actions/checkout@v4
name: Checkout
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ needs.build_parameters.outputs.container_owner }}/devcontainer-base
tags: |
type=sha,format=long,value=${GITHUB_SHA}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Sign in to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io
- name: Build and push Docker image
id: container_build_and_push
uses: docker/build-push-action@v5
with:
context: .
file: .devcontainer/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
push: true
# - name: Publish Container Image as a Status
# id: container_image_status
# uses: octodemo/github-status-action@v3
# with:
# authToken: ${{ secrets.GITHUB_TOKEN }}
# state: success
# context: Container Image Published - ${{ inputs.container_type }}
# description: ${{ fromJSON(steps.container_build_and_push.outputs.metadata)['image.name'] }}