Skip to content

Commit 61625e8

Browse files
committed
added concurrency check in the github actions
Signed-off-by: Paul Schultz <[email protected]>
1 parent d2b5460 commit 61625e8

6 files changed

+161
-138
lines changed

.github/workflows/check-architectures.yaml

+44-40
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,53 @@ name: Check Architectures
1616

1717
on:
1818
pull_request:
19-
branches: [ main ]
19+
branches: [main]
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
23+
cancel-in-progress: true
2024

2125
jobs:
2226
check_architectures:
2327
name: Check Stack and Sample Architectures
2428
runs-on: ubuntu-latest
2529
steps:
26-
- name: Checkout
27-
uses: actions/checkout@v2
28-
- name: Install yq command
29-
uses: redhat-actions/openshift-tools-installer@v1
30-
with:
31-
source: "github"
32-
github_pat: ${{ secrets.GITHUB_TOKEN }}
33-
# Installs the latest release of yq
34-
yq: "latest"
35-
- name: Get git diff
36-
id: diff
37-
uses: technote-space/get-diff-action@v4
38-
with:
39-
PATTERNS: |
40-
+(stacks)/**/devfile.yaml
41-
extraDevfileEntries.yaml
42-
- name: Print the diff
43-
run: echo git diff ${{ env.GIT_DIFF }}
44-
- name: Save PR number
45-
run: |
46-
mkdir -p ./pr
47-
echo ${{ github.event.number }} > ./pr/number
48-
- name: Check stacks and samples output
49-
continue-on-error: true
50-
run: tests/check_architectures.sh "${{ env.GIT_DIFF }}" yq >> ./pr/output
51-
- name: Find Comment in PR
52-
uses: peter-evans/find-comment@v1
53-
id: find
54-
with:
55-
issue-number: ${{ github.event.number }}
56-
comment-author: 'github-actions[bot]'
57-
body-includes: Please check if your stack/sample devfile has architectures mentioned.
58-
- name: Save Comment ID
59-
if: ${{ steps.find.outputs.comment-id != '' }}
60-
run: echo ${{ steps.find.outputs.comment-id }} > ./pr/commentid
61-
- uses: actions/upload-artifact@v2
62-
with:
63-
name: pr
64-
path: pr/
30+
- name: Checkout
31+
uses: actions/checkout@v2
32+
- name: Install yq command
33+
uses: redhat-actions/openshift-tools-installer@v1
34+
with:
35+
source: 'github'
36+
github_pat: ${{ secrets.GITHUB_TOKEN }}
37+
# Installs the latest release of yq
38+
yq: 'latest'
39+
- name: Get git diff
40+
id: diff
41+
uses: technote-space/get-diff-action@v4
42+
with:
43+
PATTERNS: |
44+
+(stacks)/**/devfile.yaml
45+
extraDevfileEntries.yaml
46+
- name: Print the diff
47+
run: echo git diff ${{ env.GIT_DIFF }}
48+
- name: Save PR number
49+
run: |
50+
mkdir -p ./pr
51+
echo ${{ github.event.number }} > ./pr/number
52+
- name: Check stacks and samples output
53+
continue-on-error: true
54+
run: tests/check_architectures.sh "${{ env.GIT_DIFF }}" yq >> ./pr/output
55+
- name: Find Comment in PR
56+
uses: peter-evans/find-comment@v1
57+
id: find
58+
with:
59+
issue-number: ${{ github.event.number }}
60+
comment-author: 'github-actions[bot]'
61+
body-includes: Please check if your stack/sample devfile has architectures mentioned.
62+
- name: Save Comment ID
63+
if: ${{ steps.find.outputs.comment-id != '' }}
64+
run: echo ${{ steps.find.outputs.comment-id }} > ./pr/commentid
65+
- uses: actions/upload-artifact@v2
66+
with:
67+
name: pr
68+
path: pr/

.github/workflows/ci.yaml

+17-13
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@ name: CI
1616

1717
on:
1818
push:
19-
branches: [ main ]
19+
branches: [main]
2020
pull_request:
21-
branches: [ main ]
21+
branches: [main]
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
25+
cancel-in-progress: true
2226

2327
jobs:
2428
build:
2529
name: Check registry build
2630
runs-on: ubuntu-latest
2731
steps:
28-
- name: Check out code
29-
uses: actions/checkout@v2
30-
with:
31-
path: registry-repo
32-
- name: Setup Go environment
33-
uses: actions/setup-go@v2
34-
with:
35-
go-version: 1.13
36-
37-
- name: Check if devfile registry build is working
38-
run: registry-repo/.ci/build.sh
32+
- name: Check out code
33+
uses: actions/checkout@v2
34+
with:
35+
path: registry-repo
36+
- name: Setup Go environment
37+
uses: actions/setup-go@v2
38+
with:
39+
go-version: 1.13
40+
41+
- name: Check if devfile registry build is working
42+
run: registry-repo/.ci/build.sh

.github/workflows/comment-pr.yaml

+53-49
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,64 @@ name: Comment on PR
1818
on:
1919
workflow_run:
2020
workflows:
21-
- "Check Architectures"
21+
- 'Check Architectures'
2222
types:
2323
- completed
2424

25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
27+
cancel-in-progress: true
28+
2529
jobs:
2630
comment:
2731
runs-on: ubuntu-latest
2832
steps:
29-
- name: Download PR artifact
30-
uses: actions/[email protected]
31-
with:
32-
script: |
33-
var artifacts = await github.actions.listWorkflowRunArtifacts({
34-
owner: context.repo.owner,
35-
repo: context.repo.repo,
36-
run_id: ${{github.event.workflow_run.id }},
37-
});
38-
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
39-
return artifact.name == "pr"
40-
})[0];
41-
var download = await github.actions.downloadArtifact({
42-
owner: context.repo.owner,
43-
repo: context.repo.repo,
44-
artifact_id: matchArtifact.id,
45-
archive_format: 'zip',
46-
});
47-
var fs = require('fs');
48-
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
49-
- run: unzip pr.zip
50-
- name: Comment on PR if there is output
51-
uses: actions/github-script@v3
52-
with:
53-
github-token: ${{ secrets.GITHUB_TOKEN }}
54-
script: |
55-
var fs = require('fs');
56-
var test_output = String(fs.readFileSync('./output'));
57-
var header = "Please check if your stack/sample devfile has architectures mentioned.\n"
58-
if (test_output) {
59-
test_output = header + test_output
60-
if (fs.existsSync('./commentid')) {
61-
var comment_id = Number(fs.readFileSync('./commentid'));
62-
await github.issues.updateComment({
63-
owner: context.repo.owner,
64-
repo: context.repo.repo,
65-
comment_id: comment_id,
66-
body: test_output
67-
});
68-
} else {
69-
var issue_number = Number(fs.readFileSync('./number'));
70-
await github.issues.createComment({
71-
owner: context.repo.owner,
72-
repo: context.repo.repo,
73-
issue_number: issue_number,
74-
body: test_output
75-
});
33+
- name: Download PR artifact
34+
uses: actions/[email protected]
35+
with:
36+
script: |
37+
var artifacts = await github.actions.listWorkflowRunArtifacts({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
run_id: ${{github.event.workflow_run.id }},
41+
});
42+
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
43+
return artifact.name == "pr"
44+
})[0];
45+
var download = await github.actions.downloadArtifact({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
artifact_id: matchArtifact.id,
49+
archive_format: 'zip',
50+
});
51+
var fs = require('fs');
52+
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
53+
- run: unzip pr.zip
54+
- name: Comment on PR if there is output
55+
uses: actions/github-script@v3
56+
with:
57+
github-token: ${{ secrets.GITHUB_TOKEN }}
58+
script: |
59+
var fs = require('fs');
60+
var test_output = String(fs.readFileSync('./output'));
61+
var header = "Please check if your stack/sample devfile has architectures mentioned.\n"
62+
if (test_output) {
63+
test_output = header + test_output
64+
if (fs.existsSync('./commentid')) {
65+
var comment_id = Number(fs.readFileSync('./commentid'));
66+
await github.issues.updateComment({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
comment_id: comment_id,
70+
body: test_output
71+
});
72+
} else {
73+
var issue_number = Number(fs.readFileSync('./number'));
74+
await github.issues.createComment({
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
issue_number: issue_number,
78+
body: test_output
79+
});
80+
}
7681
}
77-
}

.github/workflows/pushimge-next.yaml

+29-26
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,39 @@ name: Next Dockerimage
1616

1717
on:
1818
push:
19-
branches: [ main ]
19+
branches: [main]
2020
repository_dispatch:
2121
types: [build]
2222

23-
jobs:
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
25+
cancel-in-progress: true
2426

27+
jobs:
2528
build:
2629
runs-on: ubuntu-latest
2730
steps:
28-
- name: Checkout registry build tools
29-
uses: actions/checkout@v2
30-
with:
31-
repository: devfile/registry-support
32-
persist-credentials: false
33-
path: registry-support
34-
- name: Check out code
35-
uses: actions/checkout@v2
36-
with:
37-
path: registry-repo
38-
- name: Setup Go environment
39-
uses: actions/setup-go@v2
40-
with:
41-
go-version: 1.13
42-
- name: Login to Quay
43-
uses: docker/login-action@v1
44-
with:
45-
registry: quay.io
46-
username: ${{ secrets.QUAY_USERNAME }}
47-
password: ${{ secrets.QUAY_PASSWORD }}
48-
- name: Build the devfile-index docker image
49-
run: registry-repo/.ci/build.sh
50-
- name: Push the devfile-index docker image
51-
run: registry-support/build-tools/push.sh quay.io/devfile/devfile-index:next
31+
- name: Checkout registry build tools
32+
uses: actions/checkout@v2
33+
with:
34+
repository: devfile/registry-support
35+
persist-credentials: false
36+
path: registry-support
37+
- name: Check out code
38+
uses: actions/checkout@v2
39+
with:
40+
path: registry-repo
41+
- name: Setup Go environment
42+
uses: actions/setup-go@v2
43+
with:
44+
go-version: 1.13
45+
- name: Login to Quay
46+
uses: docker/login-action@v1
47+
with:
48+
registry: quay.io
49+
username: ${{ secrets.QUAY_USERNAME }}
50+
password: ${{ secrets.QUAY_PASSWORD }}
51+
- name: Build the devfile-index docker image
52+
run: registry-repo/.ci/build.sh
53+
- name: Push the devfile-index docker image
54+
run: registry-support/build-tools/push.sh quay.io/devfile/devfile-index:next

.github/workflows/trigger-redeploy.yaml

+14-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ on:
1818
repository_dispatch:
1919
types: [build]
2020

21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
23+
cancel-in-progress: true
24+
2125
jobs:
2226
build:
2327
name: Check registry build
2428
runs-on: ubuntu-latest
2529
steps:
26-
- name: Check out code
27-
uses: actions/checkout@v2
28-
with:
29-
persist-credentials: false
30+
- name: Check out code
31+
uses: actions/checkout@v2
32+
with:
33+
persist-credentials: false
3034

31-
- name: Trigger Deploy to Staging
32-
run: |
33-
git config --global user.email "${{secrets.CI_ROBOT_EMAIL}}"
34-
git config --global user.name "${{secrets.CI_ROBOT_NAME}}"
35-
git commit --allow-empty -m "Trigger deploy based on devfile/${{ github.event.client_payload.repo }}@${{ github.event.client_payload.sha }}"
36-
git push "https://${{secrets.CI_ROBOT}}:${{secrets.REPO_ACCESS_TOKEN}}@github.com/devfile/registry"
35+
- name: Trigger Deploy to Staging
36+
run: |
37+
git config --global user.email "${{secrets.CI_ROBOT_EMAIL}}"
38+
git config --global user.name "${{secrets.CI_ROBOT_NAME}}"
39+
git commit --allow-empty -m "Trigger deploy based on devfile/${{ github.event.client_payload.repo }}@${{ github.event.client_payload.sha }}"
40+
git push "https://${{secrets.CI_ROBOT}}:${{secrets.REPO_ACCESS_TOKEN}}@github.com/devfile/registry"

.github/workflows/validate-devfiles.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ on:
2323
schedule:
2424
- cron: 0 5 * * *
2525

26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
28+
cancel-in-progress: true
29+
2630
env:
2731
MINIKUBE_VERSION: 'v1.27.0'
2832
KUBERNETES_VERSION: 'v1.25.2'

0 commit comments

Comments
 (0)