1+ ---
2+ name : CI
3+
4+ defaults :
5+ run :
6+ shell : bash
7+
8+ on :
9+ push :
10+ tags :
11+ - ' v[0-9]+.[0-9]+.[0-9]+' # Matches tags like v1.0.0, v2.1.5, etc. This CI gets triggered by Semantic release.
12+
13+ jobs :
14+ build :
15+ runs-on : ubuntu-latest
16+ permissions :
17+ contents : read
18+ packages : write
19+
20+ steps :
21+ - name : Checkout code
22+ uses : actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
23+
24+ - name : Set up Python
25+ uses : actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
26+ with :
27+ python-version : 3.11
28+
29+ - name : Install Ansible Builder
30+ run : |
31+ python -m pip install --upgrade pip
32+ pip install ansible-builder
33+
34+ - name : Build docker context
35+ run : |
36+ ansible-builder create -f meta/execution-environment.yml --output-filename Dockerfile
37+
38+ - name : login to GHCR
39+ uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
40+ with :
41+ registry : ghcr.io
42+ username : ${{ github.actor }}
43+ password : ${{ secrets.GITHUB_TOKEN }}
44+
45+ - name : List directories
46+ run : |
47+ ls -l ./context
48+
49+ # produce docker tags for semver if on a tag, otherwise take ref branch name
50+ # latest tag is only produced for semver operating on a tag
51+ - name : determine docker tags and labels
52+ id : meta
53+ uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5
54+ with : # labels and annotations are overwritten for image.title information
55+ context : git # git - this ensures to reference the current git context instead of workflow context (context info ref/sha)
56+ images : ghcr.io/paloaltonetworks/panos_policy_automation-rhel9
57+ tags : |
58+ type=semver,pattern=v{{version}}
59+ type=semver,pattern=v{{major}}.{{minor}}
60+ type=semver,pattern=v{{major}}
61+ type=ref,event=branch
62+ type=ref,event=tag
63+ labels : |
64+ org.opencontainers.image.title=panos_policy_automation-rhel9
65+ annotations : |
66+ org.opencontainers.image.title=panos_policy_automation-rhel9
67+
68+ - name : build and publish
69+ uses : docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
70+ with :
71+ context : " ./context/"
72+ file : " ./context/Dockerfile"
73+ push : true
74+ tags : ${{ steps.meta.outputs.tags }}
75+ labels : ${{ steps.meta.outputs.labels }}
76+ cache-from : type=gha
77+ cache-to : type=gha,mode=max
78+ provenance : ${{ inputs.release }}
0 commit comments