Skip to content

Commit 5701191

Browse files
committed
Split build and deploy workflow
1 parent 01ba036 commit 5701191

File tree

2 files changed

+60
-32
lines changed

2 files changed

+60
-32
lines changed

.github/workflows/build.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: build
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
paths:
7+
- "src/**"
8+
- "Directory.Build.props"
9+
- "Dockerfile"
10+
- ".github/workflows/deploy.yml"
11+
push:
12+
branches:
13+
- master
14+
paths:
15+
- "src/**"
16+
- "Directory.Build.props"
17+
- "Dockerfile"
18+
- ".github/workflows/deploy.yml"
19+
workflow_dispatch:
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
id-token: write
28+
contents: read
29+
steps:
30+
- uses: actions/checkout@v5
31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
- name: Login to Docker Hub
36+
uses: docker/login-action@v3
37+
with:
38+
username: ${{ secrets.DOCKERHUB_USERNAME }}
39+
password: ${{ secrets.DOCKERHUB_TOKEN }}
40+
logout: true
41+
- name: Build image
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: .
45+
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
46+
load: true
47+
pull: false
48+
no-cache: false
49+
tags: ${{ vars.IMAGE }}
50+
env:
51+
DOCKER_BUILD_SUMMARY: false
52+
DOCKER_BUILD_RECORD_UPLOAD: false

.github/workflows/deploy.yml

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,22 @@
11
name: deploy
22
on:
3-
push:
4-
branches:
5-
- master
6-
paths:
7-
- "src/**"
8-
- "Directory.Build.props"
9-
- "Dockerfile"
10-
- ".github/workflows/deploy.yml"
3+
workflow_run:
4+
workflows: ["build"]
5+
types:
6+
- completed
117
workflow_dispatch:
128
concurrency:
139
group: ${{ github.workflow }}-${{ github.ref }}
1410
cancel-in-progress: true
1511
jobs:
1612
deploy:
13+
if: github.event.workflow_run.conclusion == 'success'
1714
runs-on: ubuntu-latest
1815
environment: Azure
1916
permissions:
2017
id-token: write
2118
contents: read
2219
steps:
23-
- uses: actions/checkout@v5
24-
- name: Set up QEMU
25-
uses: docker/setup-qemu-action@v3
26-
- name: Set up Docker Buildx
27-
uses: docker/setup-buildx-action@v3
28-
- name: Login to Docker Hub
29-
uses: docker/login-action@v3
30-
with:
31-
username: ${{ secrets.DOCKERHUB_USERNAME }}
32-
password: ${{ secrets.DOCKERHUB_TOKEN }}
33-
logout: true
34-
- name: Build image
35-
uses: docker/build-push-action@v6
36-
with:
37-
context: .
38-
push: true
39-
load: true
40-
pull: false
41-
no-cache: true
42-
tags: ${{ vars.IMAGE }}
43-
env:
44-
DOCKER_BUILD_SUMMARY: false
45-
DOCKER_BUILD_RECORD_UPLOAD: false
4620
- name: Azure login
4721
uses: azure/login@v2
4822
with:
@@ -60,4 +34,6 @@ jobs:
6034
registryUsername: ${{ secrets.DOCKERHUB_USERNAME }}
6135
registryPassword: ${{ secrets.DOCKERHUB_TOKEN }}
6236
targetPort: ${{ vars.CONTAINER_PORT }}
63-
environmentVariables: ASPNETCORE_ENVIRONMENT=Production KEY_VAULT_NAME=${{ secrets.KEY_VAULT_NAME }}
37+
environmentVariables: >
38+
ASPNETCORE_ENVIRONMENT=Production
39+
KEY_VAULT_NAME=${{ secrets.KEY_VAULT_NAME }}

0 commit comments

Comments
 (0)