Skip to content

Commit af5e675

Browse files
committed
Flytte workflows til å kjøære fra dedikert push workflow
1 parent b64c919 commit af5e675

File tree

3 files changed

+28
-40
lines changed

3 files changed

+28
-40
lines changed

.github/workflows/buildAndPublish.yml

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
name: "Build and Publish"
22
on:
33
workflow_call:
4-
workflow_dispatch:
5-
workflow_run:
6-
workflows: ["Run static code validation"]
7-
types:
8-
- completed
94
concurrency:
105
group: ${{ github.workflow }}-${{ github.ref }}
116
cancel-in-progress: true
127
jobs:
138
checkChanges:
149
name: Check changes
15-
# Always run on workflow call and workflow dispatch
16-
# Only run on workflow_run if there has been a change in the src folder,
17-
# excluding markdown files
18-
if: ${{
19-
github.event_name == 'workflow_call' ||
20-
github.event_name == 'workflow_dispatch' ||
21-
(
22-
github.event_name == 'workflow_run' &&
23-
github.event.workflow_run.conclusion == 'success'
24-
)
25-
}}
2610
runs-on: ubuntu-latest
2711
outputs:
2812
continueWorkflow: ${{ steps.checkChanges.outputs.continueWorkflow }}
@@ -32,7 +16,6 @@ jobs:
3216
- name: "Checkout"
3317
uses: actions/checkout@v4
3418
with:
35-
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
3619
fetch-depth: 2
3720

3821
- name: "Check for changes in src folder"
@@ -51,15 +34,7 @@ jobs:
5134
5235
echo "${yellow}Checking if there has been changes to source code by running git diff on the src folder excluding markdown files${reset}"
5336
54-
if [ "$GITHUB_EVENT_NAME" == "workflow_run" ]; then
55-
GIT_REF="${{ github.event.workflow_run.head_branch }}"
56-
else
57-
GIT_REF="${{ github.ref_name }}"
58-
fi
59-
60-
echo "Using GIT_REF: $GIT_REF"
61-
62-
changes=$(git diff "$GIT_REF^" "$GIT_REF" --ignore-all-space --name-only -- src/)
37+
changes=$(git diff "${{ github.ref_name }}^" "${{ github.ref_name }}" --ignore-all-space --name-only -- src/)
6338
nonMarkdownChanges=""
6439
continueWorkflow=true
6540
@@ -99,7 +74,8 @@ jobs:
9974
uses: actions/checkout@v4
10075
with:
10176
fetch-depth: 0
102-
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
77+
# ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
78+
ref: ${{ github.ref_name }}
10379

10480
- name: "Set Git Config"
10581
run: |
@@ -108,8 +84,8 @@ jobs:
10884
git config --system --add safe.directory "$GITHUB_WORKSPACE"
10985
11086
- name: Authenticate node
87+
if: ${{ github.ref_name == 'main' }}
11188
uses: navikt/sf-platform/.github/actions/authenticateNode@main
112-
if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') || github.ref_name }}
11389

11490
- name: Authenticate DevHub
11591
uses: navikt/sf-platform/.github/actions/authenticateOrg@main
@@ -123,8 +99,8 @@ jobs:
12399
with:
124100
devhub: "devhub"
125101
pools: "ciPlatform"
126-
ref: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request') && github.event.workflow_run.head_sha || '' }}
127-
baseRef: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request') && github.event.workflow_run.pull_requests.base.sha || '' }}
102+
ref: ${{ github.event_name == 'pull_request' && github.sha || '' }}
103+
baseRef: ${{ github.event_name == 'pull_request' && github.sha || '' }}
128104

129105
- name: Quick build
130106
uses: navikt/sf-platform/.github/actions/ciQuickBuild@main
@@ -133,30 +109,30 @@ jobs:
133109
uses: navikt/sf-platform/.github/actions/build@main
134110

135111
- name: Publish artifacts
112+
if: ${{ github.ref_name == 'main' }}
136113
uses: navikt/sf-platform/.github/actions/publishArtifact@main
137-
if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') || github.ref_name == 'main' }}
138114
with:
139115
nodeToken: ${{ secrets.GITHUB_TOKEN }}
140116

141117
- name: Generate Release Name
142-
if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') || github.ref_name == 'main' }}
118+
if: ${{ github.ref_name == 'main' }}
143119
id: generate_name
144120
run: |
145121
echo "releaseName=sf-platform_$(date +%s%3N)" >> $GITHUB_OUTPUT
146122
147123
- name: Generate Release Definition
148-
if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') || github.ref_name == 'main' }}
124+
if: ${{ github.ref_name == 'main' }}
149125
uses: navikt/sf-platform/.github/actions/generateReleaseDefinition@main
150126
with:
151-
branchToCommitTo: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
152-
gitRef: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
127+
branchToCommitTo: ${{ github.ref_name }}
128+
gitRef: ${{ github.sha }}
153129
pathToConfigFile: config/releaseConfig.yml
154130
releaseName: ${{ steps.generate_name.outputs.releaseName }}
155131
directory: "release-definition"
156132

157133
- name: Upload artifacts and logs
158-
uses: navikt/sf-platform/.github/actions/uploadWorkflowArtifactsAndLogs@main
159134
if: always()
135+
uses: navikt/sf-platform/.github/actions/uploadWorkflowArtifactsAndLogs@main
160136
with:
161137
artifactName: "build-artifacts"
162138
uploadArtifacts: true

.github/workflows/ciStaticCodeValidation.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "Run static code validation"
22
on:
3-
push:
3+
# push:
44
workflow_call:
55
inputs:
66
validateEntireRepo:
@@ -35,9 +35,9 @@ jobs:
3535
echo "GIT_REF=${{ github.event.inputs.gitRef || github.ref }}" >> $GITHUB_ENV
3636
echo "VALIDATE_ENTIRE_REPO=${{ github.event.inputs.validateEntireRepo }}" >> $GITHUB_ENV
3737
38-
if [ "${{ github.event_name }}" == "push" ]; then
39-
echo "VALIDATE_ENTIRE_REPO=false" >> $GITHUB_ENV
40-
fi
38+
# if [ "${{ github.event_name }}" == "push" ]; then
39+
# echo "VALIDATE_ENTIRE_REPO=false" >> $GITHUB_ENV
40+
# fi
4141
4242
- name: "Install SF CLI"
4343
uses: navikt/sf-platform/.github/actions/installSfCli@main

.github/workflows/onPush.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: On PUSH
2+
on:
3+
push:
4+
jobs:
5+
staticCodeValidation:
6+
uses: navikt/sf-platform/.github/workflows/ciStaticCodeValidation.yml@main
7+
with:
8+
# As we're not working with legacy we want to have everything in ship shape
9+
validateEntireRepo: "true"
10+
buildAndPublish:
11+
needs: staticCodeValidation
12+
uses: navikt/sf-platform/.github/workflows/buildAndPublish.yml@main

0 commit comments

Comments
 (0)