-
Notifications
You must be signed in to change notification settings - Fork 10
50 lines (43 loc) · 1.58 KB
/
build.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
name: Build Container Image
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [main, 'release/*']
env:
STABLE_TAG: ${{ github.event_name == 'push' && github.ref_name || format('pr-{0}', github.event.pull_request.number) }}
# We had a problem with GitHub setting quay expiration label also during
# merge to main, so we just set meaningless value as a workaround.
EXPIRATION_LABEL: ${{ github.event_name == 'push' && 'quipucords.source=github' || 'quay.expires-after=5d' }}
IMAGE_NAME: ${{ vars.IMAGE_NAME || 'quipucords/qpc' }}
REGISTRY: ${{ vars.REGISTRY || 'quay.io' }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # fetches all commits/tags
- name: Build qpc image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.STABLE_TAG }} ${{ env.STABLE_TAG == 'main' && 'latest' || '' }}
containerfiles: |
./Dockerfile
labels: |
${{ env.EXPIRATION_LABEL }}
quipucords.cli.git_sha=${{ github.sha }}
- name: Push To quay.io
# Forks that do not set these secrets and may fail this step.
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAYIO_USERNAME }}
password: ${{ secrets.QUAYIO_PASSWORD }}