forked from ansible/awx-ee
-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (119 loc) · 4.48 KB
/
release.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
# This workflow will build and push an AWX EE image to a container registry based upon the provided configuration
#
# Image tags will be generated based upon the event that triggered the workflow:
# - push event:
# - main branch: latest
# - devel branch: devel
# - all other branches: <branch name>-latest
# Branches must be added to the on.push.branches array above to trigger
# - pull_request event: DEV-PR-<pull_request_number>
# Branches must be added to the on.pull_request.branches array above to trigger
# - release event: <tag_name>
# - schedule event: nightly
# This will be the same configuration as the 'latest' tag, but may contain updated packages, etc. from upstream
# - all other events: <first 7 chars of commit sha>
#
# Variables:
# IMAGE_REGISTRY_URL: The container registry to push the image to (default: ghcr.io)
# IMAGE_REPOSITORY: The repository to push the image to (default: github.repository)
# IMAGE_REGISTRY_USER: The username to authenticate with the container registry (default: github.actor)
#
# Secrets:
# IMAGE_REGISTRY_TOKEN: The token to authenticate with the container registry (default: secrets.GITHUB_TOKEN)
#
name: Build & Release
on:
push:
# build and push anytime commits are merged to specified branches
branches:
- main
- devel
paths:
- ".github/workflows/release.yml"
- "./**"
- '!**/*.md'
pull_request:
# build and push anytime a pull request is opened or synchronized
branches:
- main
- devel
- build-runner # Remove this line before merging to 'main' or 'devel'
paths:
- ".github/workflows/release.yml"
- "./**"
- '!**/*.md'
release:
# build and push anytime a release is created
types:
- created
schedule:
# build and push nightly
- cron: "13 4 * * *"
jobs:
ci:
runs-on: ubuntu-latest
name: CI Build (Podman)
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
- name: Build EE with Podman
run: |
ansible-builder build -v3 -t ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }} --container-runtime=podman
release:
runs-on: ubuntu-latest
name: Release
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
- name: Login to Docker Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}
username: ${{ vars.IMAGE_REGISTRY_USER || github.actor }}
password: ${{ secrets.IMAGE_REGISTRY_TOKEN || secrets.GITHUB_TOKEN }}
- name: Generate image tag
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
elif [[ "${{ github.ref_name }}" == "devel" ]]; then
echo "IMAGE_TAG=devel" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}-latest" >> $GITHUB_ENV
fi
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "IMAGE_TAG=DEV-PR-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "release" ]]; then
echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "IMAGE_TAG=nightly" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_ENV
fi
- name: Build and push image
run: |
docker buildx create --name awx-ee-buildx
docker buildx use awx-ee-buildx
ansible-builder create -v3 --output-file=Dockerfile
docker buildx build \
--push \
--platform=linux/amd64,linux/arm64 \
--tag=${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }} \
context