chore(deps): update actions/checkout digest to 6b42224 #77
Workflow file for this run
This file contains 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 | |
on: | |
push: | |
branches: [ 'main' ] | |
pull_request: | |
env: | |
REGISTRY: ghcr.io | |
NAMESPACED_REGISTRY: ghcr.io/apollographql/ci-utility-docker-images | |
jobs: | |
calculate-images-to-build: | |
name: Calculate Images To Build | |
runs-on: ubuntu-latest | |
outputs: | |
changed_dirs: ${{ steps.filter_config_directories.outputs.changed_dirs }} | |
steps: | |
- name: "Checkout repository" | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 | |
- name: "Calculate changed files directories" | |
id: calculate_changed_files | |
uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c | |
with: | |
dir_names: true | |
dir_names_exclude_current_dir: true | |
json: true | |
- name: "Filter out config directories" | |
id: filter_config_directories | |
run: | | |
CHANGED_DIRS=$(echo "${{ steps.calculate_changed_files.outputs.all_changed_files }}" | jq -c '[.[] | select(. | contains(".") | not)']) | |
echo "changed_dirs=$CHANGED_DIRS" >> "$GITHUB_OUTPUT" | |
build-and-push-images: | |
name: Build and Push Docker Image | |
if: ${{ needs.calculate-images-to-build.outputs.changed_dirs != '' && toJson(fromJson(needs.calculate-images-to-build.outputs.changed_dirs)) != '[]' }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
attestations: write | |
id-token: write | |
needs: | |
- calculate-images-to-build | |
strategy: | |
matrix: | |
changed_dir: ${{ fromJSON(needs.calculate-images-to-build.outputs.changed_dirs ) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 | |
- name: Log in to the Container Registry | |
uses: docker/login-action@29df2a9f8c71c2dfe7db598180a0460355ec1c00 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Details From config.yml | |
id: extract_from_config_yaml | |
run: | | |
echo "desired_version=$(cat ${{ github.workspace }}/${{ matrix.changed_dir }}/config.yml | yq '.version')" >> "$GITHUB_OUTPUT" | |
echo "platforms=$(cat ${{ github.workspace }}/${{ matrix.changed_dir }}/config.yml | yq '.platforms | join(",")')" >> "$GITHUB_OUTPUT" | |
echo "description=$(cat ${{ github.workspace }}/${{ matrix.changed_dir }}/config.yml | yq '.description')" >> "$GITHUB_OUTPUT" | |
- name: Check Image to Build Does Not Already Exist | |
run: | | |
if docker manifest inspect ${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }}:${{ steps.extract_from_config_yaml.outputs.desired_version }} > /dev/null; then | |
echo "The tag "${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }}:${{ steps.extract_from_config_yaml.outputs.desired_version }}" already exists in the repository. Do you need to bump the version in the config.yml?" | |
exit 1 | |
fi | |
- name: Calculate Version | |
id: calculate_version | |
run: | | |
VERSION=${{ github.event_name == 'pull_request' && format('{0}-PR{1}.{2}', steps.extract_from_config_yaml.outputs.desired_version, github.event.number, github.event.pull_request.head.sha) || steps.extract_from_config_yaml.outputs.desired_version}} | |
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@8026d2bc3645ea78b0d2544766a1225eb5691f89 | |
- name: Get Docker Metadata | |
id: meta | |
uses: docker/metadata-action@70b2cdc6480c1a8b86edf1777157f8f437de2166 | |
env: | |
DOCKER_METADATA_PR_HEAD_SHA: true | |
with: | |
images: ${{ env.NAMESPACED_REGISTRY }}/${{ matrix.changed_dir }} | |
tags: | | |
type=semver,pattern={{version}},value=v${{ steps.calculate_version.outputs.version }} | |
type=sha,prefix= | |
labels: | | |
org.opencontainers.image.title=${{ matrix.changed_dir }} | |
org.opencontainers.image.description=${{ steps.extract_from_config_yaml.outputs.description }} | |
org.opencontainers.image.vendor=Apollo GraphQL | |
org.opencontainers.image.licenses=MIT | |
annotations: | | |
org.opencontainers.image.title=${{ matrix.changed_dir }} | |
org.opencontainers.image.description=${{ steps.extract_from_config_yaml.outputs.description }} | |
org.opencontainers.image.vendor=Apollo GraphQL | |
org.opencontainers.image.licenses=MIT | |
- name: Build and Push Docker image | |
id: push | |
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 | |
with: | |
context: ${{ github.workspace }}/${{ matrix.changed_dir }} | |
file: ${{ github.workspace }}/${{ matrix.changed_dir }}/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: ${{ steps.extract_from_config_yaml.outputs.platforms }} | |
- name: Create Git Tag | |
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_bump: false | |
default_prerelease_bump: false | |
custom_tag: ${{ matrix.changed_dir }}/v${{ steps.calculate_version.outputs.version }} | |
dry_run: ${{ github.event_name == 'pull_request' }} | |
tag_prefix: "" | |
- name: Create GitHub Release | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: comnoco/create-release-action@7dea6dc82ac9d97ced7a764aa82811451bba80e0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ matrix.changed_dir }}/v${{ steps.calculate_version.outputs.version }} | |
release_name: ${{ matrix.changed_dir }} - v${{ steps.calculate_version.outputs.version }} | |
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 }} | |