96 lines (86 loc) · 3.16 KB
/
docker-push.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
name: Download Docker image and its tags from GitHub artifacts, apply them and push the image to container registry
env:
OWNER: ${{ github.repository_owner }}
on:
workflow_call:
inputs:
architecture:
description: Image architecture
required: true
type: string
registry:
description: Docker registry
required: true
type: string
secrets:
REGISTRY_USERNAME:
required: true
REGISTRY_TOKEN:
required: true
jobs:
tag-push:
runs-on: ubuntu-latest
strategy:
matrix:
image: [aiida-core-base, aiida-core-with-services, aiida-core-dev]
defaults:
run:
shell: bash
working-directory: .docker
permissions:
packages: write
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
- name: Create dev environment 📦
uses: ./.github/actions/create-dev-env
with:
architecture: ${{ inputs.architecture }}
- name: Load image to Docker 📥
uses: ./.github/actions/load-image
with:
image: ${{ matrix.image }}
architecture: ${{ inputs.architecture }}
- 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" >> "${GITHUB_OUTPUT}"
- name: Docker meta 📝
id: meta
uses: docker/metadata-action@v4
env: ${{ fromJson(steps.build_vars.outputs.vars) }}
with:
images: |
name=${{ inputs.registry }}/${{ env.OWNER }}/${{ matrix.image }}
tags: |
type=edge,enable={{is_default_branch}}
type=sha,enable=${{ github.ref_type != 'tag' }}
type=ref,event=pr
type=match,pattern=v(\d+\.\d+.\d+),group=1
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=python-${{ env.PYTHON_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=postgresql-${{ env.PGSQL_VERSION }},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Login to Container Registry 🔑
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Set tags for image and push 🏷️📤💾
run: |
declare -a arr=(${{ steps.meta.outputs.tags }})
for tag in "${arr[@]}"; do
arch_tag=$(echo ${tag} | sed "s/:/:${{ inputs.architecture }}-/")
docker tag ${{ env.OWNER }}/${{ matrix.image }}:newly-baked ${arch_tag}
docker push ${arch_tag}
# write tag to file
mkdir -p /tmp/aiida-core
echo ${arch_tag} >> /tmp/aiida-core/${{ matrix.image }}-${{ inputs.architecture }}-tags.txt
done
- name: Upload tags file 📤
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.registry }}-${{ matrix.image }}-${{ inputs.architecture }}-tags
path: /tmp/aiida-core/${{ matrix.image }}-${{ inputs.architecture }}-tags.txt
retention-days: 3