-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (55 loc) · 2.07 KB
/
build-image.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
name: Build and Push Image
on:
push:
tags:
- v*
branches:
- main
- feature-*
jobs:
login-build-push:
env:
IMAGE_REGISTRY_GITHUB: ghcr.io/fedora-ci/kaijs
IMAGE_REGISTRY_QUAY: quay.io/fedoraci/kaijs
USER_QUAY: fedoraci+ciboard_github_ci
name: Build and push image
runs-on: ubuntu-20.04
steps:
- name: Log in to the GitHub Container registry
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.IMAGE_REGISTRY_GITHUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Quay.io
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.IMAGE_REGISTRY_QUAY }}
username: ${{ env.USER_QUAY }}
password: ${{ secrets.PASSWORD_QUAY }}
- uses: actions/checkout@v3
- name: Set outputs
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
tags: |
${{ env.IMAGE_REGISTRY_GITHUB }}:${{ steps.vars.outputs.sha_short }}
${{ ( github.ref == 'refs/heads/main' && format('{0}:latest', env.IMAGE_REGISTRY_GITHUB) ) || '' }}
${{ ( github.ref_type == 'tag' && format('{0}:{1}', env.IMAGE_REGISTRY_GITHUB, github.ref_name) ) || '' }}
${{ env.IMAGE_REGISTRY_QUAY }}:${{ steps.vars.outputs.sha_short }}
${{ ( github.ref == 'refs/heads/main' && format('{0}:latest', env.IMAGE_REGISTRY_QUAY) ) || '' }}
${{ ( github.ref_type == 'tag' && format('{0}:{1}', env.IMAGE_REGISTRY_QUAY, github.ref_name) ) || '' }}
containerfiles: |
./Dockerfile
- name: Push to Repositories
id: push-to-repo
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-repo.outputs.registry-paths }}"
# vim: noai:ts=2:sw=2 et