-
Notifications
You must be signed in to change notification settings - Fork 36
73 lines (67 loc) · 2.24 KB
/
build-and-push.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
name: Rebuild & push images
on:
push:
branches:
- main
- stable
jobs:
build-n-push:
# To not run in forks
if: github.repository_owner == 'packit'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- dockerfile: Dockerfile
image: dashboard
steps:
- uses: actions/checkout@v3
- name: Extract branch name and set tag
shell: bash
run: |
branch=${GITHUB_REF#refs/heads/}
tag=""
api=""
case $branch in
main)
tag="stg latest"
api="https://stg.packit.dev/api"
;;
stable)
tag="prod"
api="https://prod.packit.dev/api"
;;
esac
echo "branch=${branch}" >> $GITHUB_OUTPUT
unique_tag="${branch}-${GITHUB_SHA::7}"
echo "tag=${tag} ${unique_tag}" >> $GITHUB_OUTPUT
echo "api=${api}" >> $GITHUB_OUTPUT
echo "commit_sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
id: branch_tag
- name: Set up secret file needed for the build
run: echo "$SENTRY_AUTH_TOKEN" > /tmp/sentry-secret
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Build Image
id: build-image
# https://github.com/marketplace/actions/buildah-build
uses: redhat-actions/buildah-build@v2
with:
dockerfiles: ${{ matrix.dockerfile }}
image: ${{ matrix.image }}
tags: ${{ steps.branch_tag.outputs.tag }}
build-args: |
VITE_API_URL=${{ steps.branch_tag.outputs.api }}
VITE_GIT_SHA=${{ steps.branch_tag.outputs.commit_sha }}
extra-args: |
--secret id=sentry_auth_token,src=/tmp/sentry-secret
oci: true
- name: Push To Quay
# https://github.com/marketplace/actions/push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/packit
username: ${{ secrets.QUAY_IMAGE_BUILDER_USERNAME }}
password: ${{ secrets.QUAY_IMAGE_BUILDER_TOKEN }}