-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 2.4 KB
/
publish.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
---
name: Publish image to Docker container registries
env:
# https://github.com/docker/metadata-action?tab=readme-ov-file#environment-variables
DOCKER_METADATA_PR_HEAD_SHA: true
REPO_NAME: quantum-espresso
on:
workflow_call:
inputs:
runsOn:
description: GitHub Actions Runner image
required: true
type: string
image:
description: Image built in build step
required: true
type: string
registry:
description: Docker container registry
required: true
type: string
jobs:
release:
runs-on: ${{ inputs.runsOn }}
timeout-minutes: 30
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry 🔑
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Read build variables
id: build_vars
run: |
vars=$(cat build.json | jq -c '[.variable | to_entries[] | {"key": .key, "value": .value.default}] | from_entries')
echo "vars=$vars" | tee -a "${GITHUB_OUTPUT}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
env: ${{ fromJSON(steps.build_vars.outputs.vars) }}
with:
# e.g. ghcr.io/cnts4sci/python
images: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ env.REPO_NAME }}
tags: |
type=ref,event=pr
type=edge,enable={{is_default_branch}}
type=match,pattern=(\d{4}\.\d{4}(-.+)?),group=1
type=raw,value=v${{ env.VERSION }},enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }}
- name: Determine source image
id: image
run: |
echo "src=${{ inputs.image }}" | tee -a "${GITHUB_OUTPUT}"
- name: Push image
uses: akhilerm/[email protected]
with:
src: ${{ steps.image.outputs.src }}
dst: ${{ steps.meta.outputs.tags }}