fix tagging #1715
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
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
types: [ opened, reopened, synchronize ] | |
workflow_call: | |
inputs: | |
platforms: | |
description: 'Platforms to build for' | |
required: false | |
type: string | |
latest: | |
description: 'Tag image as latest' | |
required: false | |
type: boolean | |
default: false | |
push: | |
description: 'Push image to registry (makes it push if it usually wouldnt)' | |
required: false | |
type: boolean | |
default: false | |
tag-prefix: | |
description: 'Tag prefix to use' | |
required: false | |
type: string | |
default: 'rn' | |
workflow_dispatch: | |
name: ci-build | |
env: | |
REGISTRY: ghcr.io | |
DOTNET_VERSION: 9.0.x | |
jobs: | |
tests: | |
name: Tests (${{ matrix.name }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: common-unit | |
project: Common.Tests/Common.Tests.csproj | |
- name: api-integration | |
project: API.IntegrationTests/API.IntegrationTests.csproj | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v5 | |
- uses: actions/setup-dotnet@v5 | |
with: | |
dotnet-version: '${{ env.DOTNET_VERSION }}' | |
- name: Run ${{ matrix.name }} tests | |
run: | | |
set -euo pipefail | |
dotnet test -c Release ${{ matrix.project }} | |
build: | |
name: Build (${{ matrix.image }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dockerfile: docker/API.Dockerfile | |
image: api | |
- dockerfile: docker/LiveControlGateway.Dockerfile | |
image: live-control-gateway | |
- dockerfile: docker/Cron.Dockerfile | |
image: cron | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v5 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build ${{ matrix.image }} | |
uses: ./.github/actions/build-app | |
with: | |
dockerfile: ${{ matrix.dockerfile }} | |
push: ${{ inputs.push || (github.ref_protected && github.event_name != 'pull_request') }} | |
image: ${{ matrix.image }} | |
platforms: ${{ inputs.platforms || 'linux/amd64' }} | |
tag-prefix: ${{ inputs.tag-prefix }} | |
promote-image: | |
name: Promote Image (${{ matrix.image }}) | |
needs: [build, tests] | |
runs-on: ubuntu-latest | |
if: ${{ inputs.push || (github.ref_protected && github.event_name != 'pull_request') }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- image: api | |
- image: live-control-gateway | |
- image: cron | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v5 | |
- name: Log in to Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Promote Manifest ${{ matrix.image }} | |
uses: ./.github/actions/promote-image | |
with: | |
image: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image }} | |
run-tag: ${{ inputs.tag-prefix }}-${{ github.run_number }}-a${{ github.run_attempt }} | |
latest: ${{ inputs.latest || false }} | |
deploy-prod-workflow: | |
runs-on: ubuntu-latest | |
needs: promote-image | |
if: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
environment: production | |
steps: | |
- name: Send repository dispatch | |
uses: peter-evans/repository-dispatch@v4 | |
with: | |
token: ${{ secrets.GITOPS_PAT }} | |
repository: openshock/kubernetes-cluster-gitops | |
event-type: update-backend-prod | |
client-payload: | | |
{ | |
"tag": "${{ inputs.tag-prefix }}-${{ github.run_number }}-a${{ github.run_attempt }}" | |
} | |
deploy-staging: | |
runs-on: ubuntu-latest | |
needs: promote-image | |
if: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && github.ref_name == 'develop' }} | |
environment: staging | |
steps: | |
- name: Send repository dispatch | |
uses: peter-evans/repository-dispatch@v4 | |
with: | |
token: ${{ secrets.GITOPS_PAT }} | |
repository: openshock/kubernetes-cluster-gitops | |
event-type: update-backend-staging | |
client-payload: | | |
{ | |
"tag": "${{ inputs.tag-prefix }}-${{ github.run_number }}-a${{ github.run_attempt }}" | |
} | |
deploy-dev: | |
runs-on: ubuntu-latest | |
needs: promote-image | |
if: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && github.ref_name == 'develop' }} | |
environment: development | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
sparse-checkout: | | |
.github | |
- uses: ./.github/actions/watchtower-update | |
with: | |
url: ${{ vars.WATCHTOWER_URL }} | |
token: ${{ secrets.WATCHTOWER_TOKEN }} |