Skip to content

Commit 8588603

Browse files
authored
Merge pull request #434 from zmiklank/use_new_build_and_push
use composite build-and-push-action
2 parents 721d100 + 9faa54d commit 8588603

File tree

1 file changed

+29
-104
lines changed

1 file changed

+29
-104
lines changed

.github/workflows/build-and-push.yml

Lines changed: 29 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -3,133 +3,58 @@ on:
33
push:
44
branches:
55
- master
6+
schedule:
7+
- cron: '0 1 * * 3'
68

79
jobs:
810
build-and-push:
11+
if: github.repository_owner == 'sclorg'
912
runs-on: ubuntu-latest
1013
strategy:
1114
fail-fast: false
1215
matrix:
1316
include:
14-
- version: "9.6"
17+
- dockerfile_path: "10"
1518
dockerfile: "Dockerfile"
1619
registry_namespace: "centos7"
1720
tag: "centos7"
18-
- version: "10"
21+
quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
22+
quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
23+
- dockerfile_path: "11"
1924
dockerfile: "Dockerfile"
2025
registry_namespace: "centos7"
2126
tag: "centos7"
22-
- version: "11"
27+
quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
28+
quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
29+
- dockerfile_path: "12"
2330
dockerfile: "Dockerfile"
2431
registry_namespace: "centos7"
2532
tag: "centos7"
26-
- version: "12"
33+
quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
34+
quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
35+
- dockerfile_path: "13"
2736
dockerfile: "Dockerfile"
2837
registry_namespace: "centos7"
2938
tag: "centos7"
30-
- version: "13"
31-
dockerfile: "Dockerfile"
32-
registry_namespace: "centos7"
33-
tag: "centos7"
34-
- version: "13"
39+
quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
40+
quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
41+
- dockerfile_path: "13"
3542
dockerfile: "Dockerfile.c9s"
3643
registry_namespace: "sclorg"
3744
tag: "c9s"
45+
quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
46+
quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
3847

3948
steps:
40-
- uses: actions/checkout@v2
41-
with:
42-
fetch-depth: 0
43-
submodules: true
44-
45-
- name: Get base image name
46-
id: base-image-name
47-
run: |
48-
# This command returns row with BASE_IMAGE_NAME
49-
row=$(grep "BASE_IMAGE_NAME" Makefile)
50-
# Return only base image name
51-
BASE_IMAGE_ROW=${row/BASE_IMAGE_NAME = /}
52-
echo ::set-output name=image_name::$BASE_IMAGE_ROW
53-
54-
- name: Install python3 packages needed by distgen
55-
run: |
56-
sudo apt-get update -y && sudo apt-get install -y python3 python3-pip
57-
58-
- name: Install dist-gen package from PyPi
59-
id: dist-gen-install
60-
run: |
61-
pip3 -v install distgen
62-
63-
- name: Get short version
64-
id: short_version
65-
run: |
66-
ver="${{ matrix.version }}"
67-
echo "::set-output name=SHORT_VER::${ver//./}"
68-
69-
- name: Generate source by dist-gen
70-
id: generate
71-
run: |
72-
DG=$HOME/.local/bin/dg make generate-all
73-
74-
- name: Login to Quay.io private registry
75-
if: ${{ matrix.tag == 'c9s' }}
76-
uses: redhat-actions/podman-login@v1
77-
with:
78-
registry: quay.io
79-
username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
80-
password: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
81-
82-
- name: Check if ${{ matrix.dockerfile }} is present in version directory
83-
id: check_dockerfile_file
84-
# https://github.com/marketplace/actions/file-existence
85-
uses: andstor/file-existence-action@v1
86-
with:
87-
files: "${{ matrix.version }}/${{ matrix.dockerfile }}"
88-
89-
- name: Check if .exclude-${{ matrix.tag }} is present in version directory
90-
id: check_exclude_file
91-
# https://github.com/marketplace/actions/file-existence
92-
uses: andstor/file-existence-action@v1
49+
- name: Build and push to quay.io registry
50+
uses: sclorg/build-and-push-action@v1
9351
with:
94-
files: "${{ matrix.version }}/.exclude-${{ matrix.tag }}"
95-
96-
- name: Build image
97-
if: steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true'
98-
id: build-image
99-
# https://github.com/marketplace/actions/buildah-build
100-
uses: redhat-actions/buildah-build@v2
101-
with:
102-
dockerfiles: ${{ matrix.version }}/${{ matrix.dockerfile }}
103-
image: ${{ steps.base-image-name.outputs.image_name}}-${{ steps.short_version.outputs.SHORT_VER }}-${{ matrix.tag }}
104-
context: ${{ matrix.version }}
105-
tags: latest ${{ matrix.tag }} ${{ github.sha }}
106-
107-
- name: Push CentOS 7 image to Quay.io
108-
if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true' && matrix.tag == 'centos7' }}
109-
id: push-to-quay-centos7
110-
uses: redhat-actions/[email protected]
111-
with:
112-
image: ${{ steps.build-image.outputs.image }}
113-
tags: ${{ steps.build-image.outputs.tags }}
114-
registry: quay.io/${{ matrix.registry_namespace }}
115-
username: ${{ secrets.QUAY_IMAGE_BUILDER_USERNAME }}
116-
password: ${{ secrets.QUAY_IMAGE_BUILDER_TOKEN }}
117-
118-
- name: Push CentOS Stream 9 image to Quay.io
119-
if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true' && matrix.tag == 'c9s' }}
120-
id: push-to-quay-sclorg
121-
uses: redhat-actions/[email protected]
122-
with:
123-
image: ${{ steps.build-image.outputs.image }}
124-
tags: ${{ steps.build-image.outputs.tags }}
125-
registry: quay.io/${{ matrix.registry_namespace }}
126-
username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
127-
password: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
128-
129-
- name: Print image url
130-
if: ${{ matrix.tag == 'centos7' }}
131-
run: echo "Image pushed to ${{ steps.push-to-quay-centos7.outputs.registry-paths }}"
132-
133-
- name: Print image url
134-
if: ${{ matrix.tag == 'c9s' }}
135-
run: echo "Image pushed to ${{ steps.push-to-quay-sclorg.outputs.registry-paths }}"
52+
registry: "quay.io"
53+
registry_namespace: ${{ matrix.registry_namespace }}
54+
registry_username: ${{ secrets[matrix.quayio_username] }}
55+
registry_token: ${{ secrets[matrix.quayio_token] }}
56+
dockerfile: ${{ matrix.dockerfile }}
57+
docker_context: ${{ matrix.dockerfile_path }}
58+
dockerfile_path: ${{ matrix.dockerfile_path }}
59+
tag: ${{ matrix.tag }}
60+
use_distgen: "true"

0 commit comments

Comments
 (0)