-
Notifications
You must be signed in to change notification settings - Fork 8
82 lines (71 loc) · 2.39 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
name: (sub) Build Docker image
defaults:
run:
shell: bash
on:
workflow_call:
inputs:
publish:
description: A flag that triggers publishing to GHCR
type: boolean
default: false
python_version:
description: A version of Python to install
type: string
required: true
tag_name:
description: A tag to checkout
type: string
jobs:
build:
name: Build ${{ inputs.publish && 'and publish' || '' }} a Docker image
runs-on: ubuntu-latest
# packages write should be needed for publish only - set permissions accordingly from calling workflow
# permissions:
# packages: write
# contents: read
steps:
- name: checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag_name }}
- name: install Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: install Poetry
uses: Gr1N/setup-poetry@v8
- name: get the tag name for new image
id: tag
run: |
echo "version_tag=$(poetry version -s)" >> $GITHUB_OUTPUT
- name: build and prepare package for containerization
run: |
poetry env use ${{ inputs.python_version }}
poetry lock
poetry build
poetry export --without-hashes --format=requirements.txt > requirements.txt
- name: determine docker tags and labels
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/paloaltonetworks/panos_upgrade_assurance
tags: |
type=raw,value=latest
type=semver,pattern=v{{version}},value=${{ steps.tag.outputs.version_tag }}
type=semver,pattern=v{{major}}.{{minor}},value=${{ steps.tag.outputs.version_tag }}
type=semver,pattern=v{{major}},value=${{ steps.tag.outputs.version_tag }}
- name: login to GHCR
if: inputs.publish
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build ${{ inputs.publish && 'and publish' || '' }}
uses: docker/build-push-action@v5
with:
context: .
push: ${{ inputs.publish }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}