Skip to content

Commit d7fad9f

Browse files
authored
build: always build dockerfile but skip pushing if PR (#368)
* build: always build dockerfile but skip pushing if PR * build: add default branch for deployment in order to skip looking it up * build: replace has-changes action with just a command
1 parent 937f825 commit d7fad9f

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

.github/workflows/nodejs.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ jobs:
2323
fetch-depth: 1
2424
repository: 'openbeta/api-server-deployment'
2525
token: ${{ secrets.GH_DEPLOYMENT_REPO_TOKEN }}
26+
ref: main
2627
- uses: imranismail/setup-kustomize@v2
2728
- run: |
2829
kustomize edit set image vnguyen/openbeta-graph-api:sha-${GITHUB_SHA}
29-
- name: Check if there are changes
30-
id: changes
31-
uses: UnicornGlobal/has-changes-action@v1.0.11
30+
- name: Check if there is any change
31+
id: get_changes
32+
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
3233
- name: Push if tag has changes
33-
if: steps.changes.outputs.changed == 1
34+
if: steps.get_changes.outputs.changed != 0
3435
run: |
3536
cd api-server-deployment/stage
3637
git config user.name github-actions
@@ -50,14 +51,15 @@ jobs:
5051
fetch-depth: 1
5152
repository: 'openbeta/api-server-deployment'
5253
token: ${{ secrets.GH_DEPLOYMENT_REPO_TOKEN }}
54+
ref: main
5355
- uses: imranismail/setup-kustomize@v2
5456
- run: |
5557
kustomize edit set image vnguyen/openbeta-graph-api:${GITHUB_REF}
56-
- name: Check if there are changes
57-
id: changes
58-
uses: UnicornGlobal/has-changes-action@v1.0.11
58+
- name: Check if there is any change
59+
id: get_changes
60+
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
5961
- name: Push if tag has changes
60-
if: steps.changes.outputs.changed == 1
62+
if: steps.get_changes.outputs.changed != 0
6163
run: |
6264
git config user.name github-actions
6365
git config user.email github-actions@github.com
@@ -67,7 +69,6 @@ jobs:
6769
# build docker image and push to registry
6870
docker:
6971
runs-on: ubuntu-22.04
70-
if: github.event_name != 'pull_request'
7172
needs: test
7273
steps:
7374
- name: 'Checkout Project'
@@ -93,7 +94,6 @@ jobs:
9394
tags: |
9495
type=ref,event=branch
9596
type=semver,pattern={{raw}}
96-
type=ref,event=pr
9797
type=sha,format=long
9898
9999
- name: Build docker image
@@ -102,7 +102,7 @@ jobs:
102102
context: ./
103103
file: ./Dockerfile
104104
builder: ${{ steps.buildx.outputs.name }}
105-
push: true
105+
push: ${{ github.event_name != 'pull_request' }}
106106
tags: ${{ steps.meta.outputs.tags }}
107107

108108
# setup basic machine to run all kinds of tests: lint, unit, integration, types

0 commit comments

Comments
 (0)