Debian Codegraph @

ansible_collections/community/docker/.github/workflows/docker-images.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 name: Helper Docker images for testing
7 'on':
8 # Run CI against all pushes (direct commits, also merged PRs), Pull Requests
9 push:
10 branches:
11 - main
12 paths:
13 - .github/workflows/docker-images.yml
14 - tests/images/**
15 pull_request:
16 branches:
17 - main
18 paths:
19 - .github/workflows/docker-images.yml
20 - tests/images/**
21 # Run CI once per day (at 03:00 UTC)
22 schedule:
23 - cron: '0 3 * * *'
24
25 env:
26 CONTAINER_REGISTRY: ghcr.io/ansible-collections
27
28 jobs:
29 build:
30 name: Build image ${{ matrix.name }}:${{ matrix.tag }}
31 runs-on: ubuntu-latest
32 strategy:
33 fail-fast: false
34 matrix:
35 include:
36 - name: simple-1
37 tag: tag
38 tag-as-latest: true
39 - name: simple-2
40 tag: tag
41 tag-as-latest: true
42 - name: healthcheck
43 tag: check
44 tag-as-latest: true
45
46 steps:
47 - name: Check out repository
48 uses: actions/checkout@v6
49 with:
50 persist-credentials: false
51
52 - name: Install dependencies
53 run: |
54 sudo apt-get install podman buildah
55
56 - name: Set up Go 1.26
57 uses: actions/setup-go@v6
58 with:
59 go-version: '1.26'
60 cache: false # true (default) results in warnings since we don't use Go modules
61
62 - name: Build ${{ matrix.name }} image
63 run: |
64 ./build.sh "${CONTAINER_REGISTRY}/${{ matrix.name }}:${{ matrix.tag }}"
65 working-directory: tests/images/${{ matrix.name }}
66
67 - name: Tag image as latest
68 if: matrix.tag-as-latest && matrix.tag != 'latest'
69 env:
70 SOURCE_IMAGE: ${{ matrix.name }}:${{ matrix.tag }}
71 DEST_IMAGE: ${{ matrix.name }}:latest
72 run: >-
73 podman tag "${CONTAINER_REGISTRY}/${SOURCE_IMAGE}" "${CONTAINER_REGISTRY}/${DEST_IMAGE}"
74
75 - name: Publish container image ${{ env.CONTAINER_REGISTRY }}/${{ matrix.name }}:${{ matrix.tag }}
76 if: github.event_name != 'pull_request'
77 env:
78 IMAGE: ${{ matrix.name }}:${{ matrix.tag }}
79 run: >-
80 podman manifest push --all "${IMAGE}" "${CONTAINER_REGISTRY}/${IMAGE}" --tls-verify=true --creds=${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}
81
82 - name: Publish container image ${{ env.CONTAINER_REGISTRY }}/${{ matrix.name }}:latest
83 if: github.event_name != 'pull_request' && matrix.tag-as-latest && matrix.tag != 'latest'
84 env:
85 IMAGE: ${{ matrix.name }}:latest
86 run: >-
87 podman manifest push --all "${IMAGE}" "${CONTAINER_REGISTRY}/${IMAGE}" --tls-verify=true --creds=${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}