Skip to content

Rework structure of CI workflow #2503

Rework structure of CI workflow

Rework structure of CI workflow #2503

Workflow file for this run

name: CI/CD
on:
push:
branches:
- 'master*'
- 'devel-*'
tags:
- '*'
pull_request:
schedule:
- cron: '0 16 * * *'
workflow_dispatch:
permissions: {}
jobs:
dependencies:
name: Test python/requirements.txt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check requirements.txt against requirements-direct.txt
run: |
(diff -w python/requirements-direct.txt python/requirements.txt || true) | (! grep -e "^<")
shell: bash
- name: Check for dependency updates
continue-on-error: true
run:
.github/upgrade-pip-packages.sh
shell: bash
test-mac:
name: "Test macOS"
uses: "./.github/workflows/test-os.yml"
with:
os: ${{ toJson([macos-11, macos-12, macos-13]) }}

Check failure on line 37 in .github/workflows/ci-cd.yml

View workflow run for this annotation

GitHub Actions / CI/CD

Invalid workflow file

The workflow is not valid. .github/workflows/ci-cd.yml (Line: 37, Col: 11): Unexpected symbol: '['. Located at position 8 within expression: toJson([macos-11, macos-12, macos-13]) .github/workflows/ci-cd.yml (Line: 43, Col: 11): Unexpected symbol: '['. Located at position 8 within expression: toJson([ubuntu-20.04, ubuntu-22.04])
test-lnx:
name: "Test Ubuntu"
uses: "./.github/workflows/test-os.yml"
with:
os: ${{ toJson([ubuntu-20.04, ubuntu-22.04]) }}
test-win:
name: "Test Windows"
uses: "./.github/workflows/test-os.yml"
with:
os: ${{ toJson([windows-2019, windows-2022]) }}
publish:
name: "Publish"
needs: [test-mac, test-lnx, test-win]
uses: "./.github/workflows/publish.yml"
permissions:
checks: write
pull-requests: write
security-events: write
config-deploy:
name: Configure Deployment
needs: [test-mac, test-lnx, test-win]
# do not build or deploy on forked repositories
if: github.repository_owner == 'EnricoMi'
runs-on: ubuntu-latest
outputs:
image: ${{ steps.action.outputs.image }}
image-exists: ${{ steps.image.outputs.exists }}
image-version: ${{ steps.action.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Extract action image and version
# we deploy from a specific commit on master (the one that mentions a new version the first time)
# so we need to tell docker/metadata-action to extract docker tags from that version
id: action
run: |
image=$(grep -A 10 "^runs:" action.yml | grep -E "^\s+image:\s" | sed -E -e "s/^\s+image:\s*'//" -e "s/docker:\/\///" -e "s/'\s*$//")
version=$(cut -d : -f 2 <<< "$image")
echo "image=$image" >>$GITHUB_OUTPUT
echo "version=$version" >>$GITHUB_OUTPUT
shell: bash
- name: Check action image existence
id: image
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
if docker manifest inspect '${{ steps.action.outputs.image }}'
then
echo "exists=true" >>$GITHUB_OUTPUT
fi
shell: bash
deploy:
name: Deploy to GitHub
needs: [publish, config-deploy]
# do not build or deploy on forked repositories
if: github.repository_owner == 'EnricoMi'
runs-on: ubuntu-latest
steps:
- name: Docker meta
id: docker-meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/EnricoMi/publish-unit-test-result-action
flavor: |
latest=false
prefix=v
tags: |
type=sha
type=ref,event=tag
type=semver,pattern={{major}},value=${{ needs.config-deploy.outputs.image-version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.config-deploy.outputs.image-version }}
type=semver,pattern={{version}},value=${{ needs.config-deploy.outputs.image-version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
pull: true
# deploy image actions from commits pushed to master and
# deploy Dockerfile actions from pushed version tags (no major versions)
push: |
${{
github.event_name == 'push' && (
needs.config-deploy.outputs.image != 'Dockerfile' && startsWith(github.ref, 'refs/heads/master') && needs.config-deploy.outputs.image-exists != 'true' ||
needs.config-deploy.outputs.image == 'Dockerfile' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
)
}}
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}