-
Notifications
You must be signed in to change notification settings - Fork 8
82 lines (70 loc) · 2.01 KB
/
custom-base-image.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
name: Custom Base Image Example
on:
push:
workflow_dispatch:
env:
GITHUB_USERNAME: baronfel
BASE_IMAGE: "ghcr.io/baronfel/dotnet-runtime-skia-base-image:8.0"
IMAGE_NAME: baronfel/skia-app
IMAGE_TAG: "8.0"
jobs:
create-base-image:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get the code
uses: actions/checkout@v4
- name: Build the base image
working-directory: src/custom-base-image
run: |
docker build -t ${{ env.BASE_IMAGE }} -f Dockerfile .
docker push ${{ env.BASE_IMAGE }}
use-base-image:
needs: create-base-image
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get .NET
uses: actions/setup-dotnet@v4
- name: Get the code
uses: actions/checkout@v4
- name: Build and publish the app
working-directory: src/custom-base-image
run: |
dotnet publish -t:PublishContainer \
-p ContainerBaseImage="${{ env.BASE_IMAGE }}" \
-p ContainerRepository="${{ env.IMAGE_NAME}}" \
-p ContainerImageTag="${{ env.IMAGE_TAG }}" \
-p ContainerRegistry=ghcr.io
run-the-image:
needs: use-base-image
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Execute the container
run: |
docker run --pull missing --rm ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}