|
3 | 3 | push: |
4 | 4 | branches: |
5 | 5 | - master |
| 6 | + schedule: |
| 7 | + - cron: '0 1 * * 3' |
6 | 8 |
|
7 | 9 | jobs: |
8 | 10 | build-and-push: |
| 11 | + if: github.repository_owner == 'sclorg' |
9 | 12 | runs-on: ubuntu-latest |
10 | 13 | strategy: |
11 | 14 | fail-fast: false |
12 | 15 | matrix: |
13 | 16 | include: |
14 | | - - version: "9.6" |
| 17 | + - dockerfile_path: "10" |
15 | 18 | dockerfile: "Dockerfile" |
16 | 19 | registry_namespace: "centos7" |
17 | 20 | tag: "centos7" |
18 | | - - version: "10" |
| 21 | + quayio_username: "QUAY_IMAGE_BUILDER_USERNAME" |
| 22 | + quayio_token: "QUAY_IMAGE_BUILDER_TOKEN" |
| 23 | + - dockerfile_path: "11" |
19 | 24 | dockerfile: "Dockerfile" |
20 | 25 | registry_namespace: "centos7" |
21 | 26 | tag: "centos7" |
22 | | - - version: "11" |
| 27 | + quayio_username: "QUAY_IMAGE_BUILDER_USERNAME" |
| 28 | + quayio_token: "QUAY_IMAGE_BUILDER_TOKEN" |
| 29 | + - dockerfile_path: "12" |
23 | 30 | dockerfile: "Dockerfile" |
24 | 31 | registry_namespace: "centos7" |
25 | 32 | tag: "centos7" |
26 | | - - version: "12" |
| 33 | + quayio_username: "QUAY_IMAGE_BUILDER_USERNAME" |
| 34 | + quayio_token: "QUAY_IMAGE_BUILDER_TOKEN" |
| 35 | + - dockerfile_path: "13" |
27 | 36 | dockerfile: "Dockerfile" |
28 | 37 | registry_namespace: "centos7" |
29 | 38 | 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" |
35 | 42 | dockerfile: "Dockerfile.c9s" |
36 | 43 | registry_namespace: "sclorg" |
37 | 44 | tag: "c9s" |
| 45 | + quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME" |
| 46 | + quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN" |
38 | 47 |
|
39 | 48 | 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 |
93 | 51 | 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