-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.09 KB
/
build-and-push-to-quay-io.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
name: Build container image and push to quay.io
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
IMAGE_REGISTRY_NAME: quay.io
IMAGE_NAME: do2day/backend
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check for required secrets
uses: actions/github-script@v4
with:
script: |
const secrets =
{
ROBOT_ACCOUNT_NAME: `${{ secrets.ROBOT_ACCOUNT_NAME }}`,
IMAGE_REGISTRY_PASSWORD: `${{ secrets.IMAGE_REGISTRY_PASSWORD }}`,
};
const missingSecrets = Object.entries(secrets).filter(([ name, value ]) =>
{
if(value.length === 0)
{
core.error(`Secret "${name}" is not set`);
}
else
{
core.info(`✔️ Secret "${name}" is set`);
}
return;
});
if(missingSecrets.length > 0)
{
core.setFailed(`❌ At least one required secret is not set in the repository. \n`);
}
else
{
core.info(`✅ All the required secrets are set`);
}
- name: Checkout repository
uses: actions/checkout@v2
- name: Determine image tags
if: env.IMAGE_TAGS == ''
run: |
echo "IMAGE_TAGS=latest ${GITHUB_SHA::12}" | tee -a $GITHUB_ENV
- name: Build from Dockerfile
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}
dockerfiles: |
./Dockerfile
- name: Push to registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY_NAME }}
username: ${{ secrets.ROBOT_ACCOUNT_NAME }}
password: ${{ secrets.IMAGE_REGISTRY_PASSWORD }}