Build & Publish Docker Images - Daily #43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Publish Docker Images - Daily | |
on: | |
schedule: | |
- cron: "0 10 * * *" # Run this job every day at 10am to get a daily build | |
workflow_dispatch: { } | |
env: | |
REGISTRY: ghcr.io | |
NAMESPACED_REGISTRY: ghcr.io/apollographql/ci-utility-docker-images | |
jobs: | |
find-all-docker-images: | |
name: "Find All Docker Images To Build" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
- id: find-all-docker-images | |
uses: ./.github/actions/find_all_docker_images | |
outputs: | |
docker_images: ${{ steps.find-all-docker-images.outputs.docker_images }} | |
build-and-push-images: | |
name: Build and Push Docker Image | |
needs: find-all-docker-images | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
attestations: write | |
id-token: write | |
strategy: | |
matrix: | |
image_directory: ${{ fromJSON(needs.find-all-docker-images.outputs.docker_images) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 | |
- name: Get current date | |
id: get-date | |
run: echo "date=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT | |
- name: Log in to the Container Registry | |
uses: docker/login-action@6d4b68b490aef8836e8fb5e50ee7b3bdfa5894f0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Details From config.yml | |
id: extract_from_config_yaml | |
uses: ./.github/actions/extract_details_from_config | |
with: | |
config_yaml_path: ${{ github.workspace }}/${{ matrix.image_directory }}/config.yml | |
- name: Build Docker Image | |
uses: ./.github/actions/build_docker_image | |
with: | |
image_description: ${{ steps.extract_from_config_yaml.outputs.description }} | |
directory: ${{ github.workspace }}/${{ matrix.image_directory }} | |
image_name: ${{ matrix.image_directory }} | |
namespaced_image_registry: ${{ env.NAMESPACED_REGISTRY }} | |
image_registry: ${{ env.REGISTRY }} | |
platforms: ${{ steps.extract_from_config_yaml.outputs.platforms }} | |
tags: | | |
type=semver,pattern={{version}},value=v${{ steps.extract_from_config_yaml.outputs.current_version }}-${{ steps.get-date.outputs.date }} | |
image_registry_password: ${{ secrets.GITHUB_TOKEN }} | |
image_registry_username: ${{ github.actor }} | |
wiz_client_secret: ${{ secrets.WIZ_CLIENT_SECRET }} | |
wiz_client_id: ${{ secrets.WIZ_CLIENT_ID }} | |
check-builds-all-completes: | |
name: Docker Images Built & Pushed | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-push-images | |
steps: | |
- run: | | |
exit ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 1 || 0 }} | |