forked from meltano/meltano
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (90 loc) · 3.34 KB
/
docker_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
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
name: Docker Publish
# This workflow will build and publish all public Docker images to the configured registry.
# Set the input `dry_run` to `false` to skip pushing images to the registry.
on:
schedule:
# Weekly on Sunday at 04:45 UTC
- cron: '45 4 * * 0'
workflow_dispatch:
inputs:
dry_run:
description: "Dry run (skip push step)"
type: boolean
required: true
default: true
registry:
description: "Where to upload the images"
required: true
type: choice
options:
- ghcr.io
- docker.io
jobs:
build_meltano_image:
runs-on: ubuntu-latest
env:
DEFAULT_PYTHON: "3.9" # will be used in 'latest' images
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Set the workflow inputs
# This step makes it so that the same workflow inputs can be accessed
# regardless of what event triggered it.
env:
DEFAULT_DRY_RUN: "true"
DEFAULT_REGISTRY: "ghcr.io"
run: |
# Boolean values don't actually work so cast to 'true' and 'false'
# https://github.com/actions/runner/issues/1483
echo "dry_run=${{ format('{0}', github.event.inputs.dry_run) || env.DEFAULT_DRY_RUN }}" >> $GITHUB_ENV
echo "registry=${{ github.event.inputs.registry || env.DEFAULT_REGISTRY }}" >> $GITHUB_ENV
- uses: actions/[email protected]
- name: Get Meltano version
id: get-meltano-version
run: |
pipx install poetry
poetry version
poetry version --short
echo "release-version=$(poetry version --short)" >> $GITHUB_OUTPUT
- name: Generate tags
id: generate-tags
run: >
python scripts/generate_docker_tags.py
--git-sha ${{ github.sha }}
-v ${{ steps.get-meltano-version.outputs.release-version }}
-p ${{ matrix.python-version }}
-d ${{ env.DEFAULT_PYTHON }}
-r ${{ env.registry }}
> tags
- name: Assemble image tags
id: assemble-tags
run: |
echo "If this is not a dry run, the image will be published with the following tags:"
cat tags
echo 'IMAGE_TAGS<<EOF' >> $GITHUB_ENV
echo "$(cat tags)" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Set registry username and password
id: user-and-pass
run: |
if [[ "${{ env.registry }}" == "ghcr.io" ]]; then
echo "username=${{ github.actor }}" >> $GITHUB_OUTPUT
echo "password=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
fi
if [[ "${{ env.registry }}" == "docker.io" ]]; then
echo "username=meltano" >> $GITHUB_OUTPUT
echo "password=${{ secrets.DOCKERHUB_TOKEN }}" >> $GITHUB_OUTPUT
fi
- name: Build, scan, then conditionally push the Docker image for a given Python version
uses: ./.github/actions/docker-build-scan-push
with:
push: ${{ env.dry_run == 'false' }}
token: ${{ secrets.GITHUB_TOKEN }}
tags: ${{ env.IMAGE_TAGS }}
registry: ${{ env.registry }}
username: ${{ steps.user-and-pass.outputs.username }}
password: ${{ steps.user-and-pass.outputs.password }}
python-version: ${{ matrix.python-version }}
meltano-version: ${{ steps.get-meltano-version.outputs.release-version }}