Skip to content

Commit 747223c

Browse files
committed
Use packaged action for what changed
1 parent f4a664c commit 747223c

File tree

1 file changed

+7
-37
lines changed

1 file changed

+7
-37
lines changed

.github/workflows/main.yaml

+7-37
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ concurrency:
77
on:
88
push:
99
paths-ignore:
10-
- "*.md"
10+
- "*.md"
1111

1212
jobs:
1313
build:
@@ -20,43 +20,14 @@ jobs:
2020
pull-requests: read
2121
steps:
2222
- uses: "actions/checkout@v4"
23-
with:
24-
fetch-depth: 0
25-
- name: Find start and end SHAs
26-
uses: nrwl/nx-set-shas@v4
27-
id: last-successful-commit-push
28-
with:
29-
main-branch-name: main
3023
- name: Determine what to do
3124
id: changed-files
32-
shell: python
33-
env:
34-
RESOURCES: nais/nais.yaml,nais/topic.yaml
35-
run: |
36-
import os
37-
import glob
38-
from itertools import chain
39-
import subprocess
40-
41-
changed_files=set(subprocess.run(["git", "diff", "--name-only", "${{ steps.last-successful-commit-push.outputs.base }}", "${{ steps.last-successful-commit-push.outputs.head }}"], capture_output=True, text=True).stdout.splitlines())
42-
print(f"::debug::Changed files: {changed_files}")
43-
resource_files = set(chain(*(glob.glob(f) for f in os.getenv("RESOURCES", "").split(","))))
44-
print(f"::debug::Resource files: {resource_files}")
45-
46-
if changed_files < resource_files:
47-
print("Only resources have been changed")
48-
output = "only-resources"
49-
elif resource_files.isdisjoint(changed_files):
50-
print("No resources have been changed")
51-
output = "non-resources"
52-
else:
53-
output = "all"
54-
55-
with open(os.getenv("GITHUB_OUTPUT"), "a") as f:
56-
f.write(f"changed={output}\n")
25+
uses: "nais/what-changed@main"
26+
with:
27+
files: "nais/nais.yaml,nais/topic.yaml"
5728
- uses: nais/platform-build-push-sign@main
5829
id: build-push-sign
59-
if: steps.changed-files.outputs.changed != 'only-resources'
30+
if: steps.changed-files.outputs.changed != 'only-inputs'
6031
with:
6132
name: karapace
6233
google_service_account: gh-karapace
@@ -74,19 +45,18 @@ jobs:
7445
- uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" # ratchet:actions/checkout@v2
7546
- uses: nais/deploy/actions/deploy@v2
7647
name: Deploy resources and image if built
77-
if: needs.build.outputs.changed != 'non-resources'
48+
if: needs.build.outputs.changed != 'non-inputs'
7849
env:
7950
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
8051
CLUSTER: dev-gcp
8152
RESOURCE: nais/nais.yaml,nais/topic.yaml
8253
WORKLOAD_IMAGE: ${{ needs.build.outputs.image }}
8354
- uses: nais/deploy/actions/deploy@v2
8455
name: Deploy only updated image
85-
if: needs.build.outputs.changed == 'non-resources'
56+
if: needs.build.outputs.changed == 'non-inputs'
8657
env:
8758
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
8859
CLUSTER: dev-gcp
8960
WORKLOAD_NAME: karapace-test
9061
WORKLOAD_IMAGE: ${{ needs.build.outputs.image }}
9162
TEAM: nais
92-

0 commit comments

Comments
 (0)