-
Notifications
You must be signed in to change notification settings - Fork 7
85 lines (77 loc) · 2.88 KB
/
containers.yaml
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
# Predefined variables for github:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#name
name: Build container images
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 22 * * *'
jobs:
test-unit:
name: Unit Tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Run Unit Tests
run: |
./test/libs/bats/bin/bats ./test/unit/*.bats
build:
name: Build Images
runs-on: ubuntu-20.04
needs: [ test-unit ]
steps:
- uses: actions/checkout@v2
- name: Get Parameters
id: getParams
run: |
source ci/config/env
echo ::set-output name=PARENT_IMG::${PARENT_IMG}
IPA_VERSION="$( docker run --rm --entrypoint "" "${PARENT_IMG}" rpm -q --qf '%{version}' freeipa-server )"
case "${GITHUB_REF}" in
"refs/heads/main" )
if [ "${{ github.event_name }}" == "schedule" ]; then
echo ::set-output name=TAGS::nightly
else
echo ::set-output name=TAGS::latest ${IPA_VERSION}
fi
echo ::set-output name=QUAY_EXPIRATION::never
;;
"refs/tags/v*" )
echo ::set-output name=TAGS::$(echo $GITHUB_REF | cut -d / -f 3) $(git rev-parse --short HEAD)
echo ::set-output name=QUAY_EXPIRATION::never
;;
* )
echo ::set-output name=TAGS::$(git rev-parse --short HEAD)
echo ::set-output name=QUAY_EXPIRATION::2w
;;
esac
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: freeipa-openshift-container
tags: ${{ steps.getParams.outputs.TAGS }}
dockerfiles: |
./Dockerfile
build-args: |
PARENT_IMG=${{ steps.getParams.outputs.PARENT_IMG }}
QUAY_EXPIRATION=${{ steps.getParams.outputs.QUAY_EXPIRATION }}
- name: Push To quay.io
# Secrets are not accessible on pull_request events
if: ${{ github.event_name != 'pull_request' }}
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ secrets.REGISTRY_SCOPE }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print image url
# This depends on the above step, so apply the same filter to match
if: ${{ github.event_name != 'pull_request' }}
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"