Skip to content

Commit 3347d17

Browse files
authored
feat: deploy is input (#66)
* feat: deploy is input * fix: login on pr * fix: don't deploy on main
1 parent ae036ab commit 3347d17

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

.github/workflows/build-container.yaml

+5-15
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@ on:
1111
workflow_dispatch:
1212

1313
jobs:
14-
container_build_and_test_job:
15-
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
16-
runs-on: ubuntu-latest
17-
name: container build ⚙️
18-
steps:
19-
- name: Checkout repository
20-
uses: actions/checkout@v4
21-
22-
# Build and push Docker image with Buildx (don't push on PR)
23-
# https://github.com/docker/build-push-action
24-
- name: Build and push Docker image
25-
uses: docker/build-push-action@v6
26-
with:
27-
context: ./
28-
push: false
14+
container-build:
15+
uses: ./.github/workflows/shared-build-and-deploy.yaml
16+
with:
17+
deploy: false
18+
secrets: inherit

.github/workflows/deploy.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
- main
88
# Publish semver tags as releases.
99
tags: ["v*.*.*"]
10-
pull_request:
11-
branches:
12-
- main
10+
# pull_request:
11+
# branches:
12+
# - main
1313
workflow_dispatch:
1414

1515
# env:
@@ -21,6 +21,8 @@ on:
2121
jobs:
2222
build-and-deploy:
2323
uses: ./.github/workflows/shared-build-and-deploy.yaml
24+
with:
25+
deploy: true
2426
secrets: inherit
2527
# build:
2628
# runs-on: ubuntu-latest

.github/workflows/shared-build-and-deploy.yaml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
on:
22
workflow_call:
3-
# inputs:
4-
# config-path:
5-
# required: true
6-
# type: string
3+
inputs:
4+
deploy:
5+
required: true
6+
type: boolean
77
# secrets:
88
# personal_access_token:
99
# required: true
@@ -41,7 +41,7 @@ jobs:
4141
# Login against a Docker registry except on PR
4242
# https://github.com/docker/login-action
4343
- name: Log into registry ${{ env.REGISTRY }}
44-
if: github.event_name != 'pull_request'
44+
# if: github.event_name != 'pull_request'
4545
uses: docker/login-action@v3
4646
with:
4747
registry: ${{ env.REGISTRY }}
@@ -69,13 +69,14 @@ jobs:
6969
uses: docker/build-push-action@v6
7070
with:
7171
context: ./
72-
push: ${{ github.event_name != 'pull_request' }}
72+
# push: ${{ github.event_name != 'pull_request' }}
73+
push: ${{ inputs.deploy }}
7374
tags: ${{ steps.meta.outputs.tags }}
7475
labels: ${{ steps.meta.outputs.labels }}
7576

7677
deploy:
7778
runs-on: ubuntu-latest
78-
if: github.event_name != 'pull_request'
79+
if: inputs.deploy == true
7980
needs: [build]
8081
permissions:
8182
id-token: write

0 commit comments

Comments
 (0)