-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (99 loc) · 3.53 KB
/
docker.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: Publish Docker image
on:
workflow_dispatch:
inputs:
environment:
description: "Environment to run tests against"
required: true
type: choice
options:
- ref
- abn
- production
branch:
description: "Branch to run the workflow on"
required: true
default: "main"
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME_APP: visualize-admin/electricity-prices-switzerland
IMAGE_NAME_SCREENSHOT: visualize-admin/elcom-strompreise-screenshot
jobs:
push_to_registry:
name: Push Docker image to Github Container registry
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Create fake wiki content
run: echo "[]" > src/wiki-content.json
# Build app
- name: Extract metadata (tags, labels) for Docker
id: meta-app
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME_APP}}
# Default value for tags + added the type=raw line
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=env-app-${{ inputs.environment }}
- name: Log in to Github Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker image
id: push-app
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta-app.outputs.tags }}
labels: ${{ steps.meta-app.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_APP}}
subject-digest: ${{ steps.push-app.outputs.digest }}
push-to-registry: true
# Build screenshot
- name: Extract metadata (tags, labels) for Docker
id: meta-screenshot
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.IMAGE_NAME_SCREENSHOT}}
# Default value for tags + added the type=raw line
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=env-app-${{ inputs.environment }}
- name: Build and push Docker image
id: push-screenshot
uses: docker/build-push-action@v6
with:
context: ./screenshot-service
file: ./screenshot-service/Dockerfile
push: true
tags: ${{ steps.meta-app.outputs.tags }}
labels: ${{ steps.meta-screenshot.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_SCREENSHOT}}
subject-digest: ${{ steps.push-app.outputs.digest }}
push-to-registry: true