Debian Codegraph @

ansible_collections/community/dns/.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: Mirror 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 pull_request:
15 branches:
16 - main
17 paths:
18 - .github/workflows/docker-images.yml
19 # Run CI once per day (at 04:00 UTC)
20 schedule:
21 - cron: '0 3 * * *'
22
23 env:
24 CONTAINER_REGISTRY: ghcr.io/ansible-collections
25 DESTINATION_REPO: ansible-collections/community.dns
26
27 jobs:
28 build:
29 name: Mirror image ${{ matrix.name }}:${{ matrix.tag }}
30 runs-on: ubuntu-latest
31 strategy:
32 fail-fast: false
33 matrix:
34 include:
35 - name: adguardhome
36 tag: latest
37 tag-as-latest: false
38 source: docker.io/adguard/adguardhome:latest
39
40 steps:
41 - name: Install dependencies
42 run: |
43 sudo apt-get install buildah podman
44
45 - name: Pull, adjust, and tag image
46 env:
47 SOURCE_IMAGE: ${{ matrix.source }}
48 DEST_IMAGE: ${{ env.CONTAINER_REGISTRY }}/${{ matrix.name }}:${{ matrix.tag }}
49 run: >-
50 echo "FROM ${SOURCE_IMAGE}"
51 |
52 podman build --annotation "org.opencontainers.image.source=https://github.com/${DESTINATION_REPO}" -t "${DEST_IMAGE}" -
53
54 - name: Tag image as latest
55 if: matrix.tag-as-latest && matrix.tag != 'latest'
56 env:
57 SOURCE_IMAGE: ${{ matrix.name }}:${{ matrix.tag }}
58 DEST_IMAGE: ${{ matrix.name }}:latest
59 run: >-
60 podman tag "${CONTAINER_REGISTRY}/${SOURCE_IMAGE}" "${CONTAINER_REGISTRY}/${DEST_IMAGE}"
61
62 - name: Publish container image ${{ env.CONTAINER_REGISTRY }}/${{ matrix.name }}:${{ matrix.tag }}
63 if: github.event_name != 'pull_request'
64 env:
65 IMAGE: ${{ matrix.name }}:${{ matrix.tag }}
66 run: >-
67 podman push "${IMAGE}" "${CONTAINER_REGISTRY}/${IMAGE}" --tls-verify=true --creds=${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}
68
69 - name: Publish container image ${{ env.CONTAINER_REGISTRY }}/${{ matrix.name }}:latest
70 if: github.event_name != 'pull_request' && matrix.tag-as-latest && matrix.tag != 'latest'
71 env:
72 IMAGE: ${{ matrix.name }}:latest
73 run: >-
74 podman push "${IMAGE}" "${CONTAINER_REGISTRY}/${IMAGE}" --tls-verify=true --creds=${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}