ci: Group workflows in queues to avoid race conditions #1404
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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
paths-ignore: | |
- docs/* | |
- docs/sources/** | |
branches: | |
- main | |
env: | |
BUNDLEWATCH_GITHUB_TOKEN: ${{secrets.BUNDLEWATCH_GITHUB_TOKEN}} | |
# Required to create OIDC/JWT token required to use shared actions | |
permissions: | |
contents: read | |
pull-requests: write | |
id-token: write | |
# This ensures builds in main are queued instead of running in parallel to ensure there's no race condition to | |
# deploy dev environment from main with Argo. At the same time we don't cancel in progress workflows to ensure they finish | |
# to give feedback about the build for each commit. See also https://github.com/grafana/explore-profiles/issues/440 | |
# for more information. | |
concurrency: | |
group: ${{ github.ref }} # ensures workflows in the same branch are grouped together | |
cancel-in-progress: false # ensures workflows do not cancel each other, they will queue instead | |
jobs: | |
build: | |
name: Build and test | |
if: github.actor != 'databases-frontend-ci-bot[bot]' | |
uses: ./.github/workflows/build.yml | |
with: | |
e2e: true | |
upload: | |
name: Upload to GCS | |
needs: [build] | |
uses: ./.github/workflows/upload.yml | |
secrets: inherit | |
with: | |
version: ${{ github.event.pull_request.head.sha || github.sha }} | |
github_environment: ${{ github.event_name != 'push' && 'gcs' || 'gcs-no-approval' }} | |
deploy-main-to-dev-and-ops: | |
name: Deploy | |
needs: [upload] | |
uses: ./.github/workflows/deploy.yml | |
# Make deployments available only from main | |
if: github.event_name == 'push' | |
secrets: inherit | |
strategy: | |
matrix: | |
environment: [dev, ops] | |
with: | |
version: ${{ github.event.pull_request.head.sha || github.sha }} | |
environment: ${{ matrix.environment }} |