Skip to content

Commit 9034708

Browse files
committed
update ci
1 parent e982517 commit 9034708

File tree

5 files changed

+65
-10
lines changed

5 files changed

+65
-10
lines changed

.github/workflows/_check.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
workflow_call:
3+
outputs:
4+
branch-pr:
5+
description: The PR number if the branch is in one
6+
value: ${{ jobs.pr.outputs.branch-pr }}
7+
8+
jobs:
9+
pr:
10+
runs-on: "ubuntu-latest"
11+
outputs:
12+
branch-pr: ${{ steps.script.outputs.result }}
13+
steps:
14+
- uses: actions/github-script@v7
15+
id: script
16+
if: github.event_name == 'push'
17+
with:
18+
script: |
19+
const prs = await github.rest.pulls.list({
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
head: context.repo.owner + ':${{ github.ref_name }}'
23+
})
24+
if (prs.data.length) {
25+
console.log(`::notice ::Skipping CI on branch push as it is already run in PR #${prs.data[0]["number"]}`)
26+
return prs.data[0]["number"]
27+
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
name: "Release dev container features & Generate Documentation"
22
on:
3+
# use this to test releasing of the devcontainer features in a branch
34
workflow_dispatch:
4-
push:
5-
branches:
6-
- main
5+
workflow_call:
76

87
jobs:
98
deploy:
109
runs-on: ubuntu-latest
1110
permissions:
1211
contents: write
13-
pull-requests: write
1412
packages: write
1513
steps:
1614
- uses: actions/checkout@v4
1715

1816
- name: patch in version tag
19-
# patch the version tag if the version is a valid semver. If not the
20-
# default to the
17+
# patch the version tag if the version is a valid semver. If not then
18+
# default to 0.0.0-b1 (only when using workflow_dispatch for tests)
2119
run: |
2220
if [[ ${{ github.ref_name }} =~ ^[0-9]+\.[0-9]+.+ ]] ; then
2321
sed -i s/0\.0\.0-b1/${{ github.ref_name }}/ $(find .devcontainer -name devcontainer-feature.json)
@@ -35,6 +33,9 @@ jobs:
3533
env:
3634
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3735

36+
# the example features publishes docs like below - I believe this is only
37+
# relevant if publishing to the marketplace?
38+
3839
# - name: Create PR for Documentation
3940
# id: push_image_info
4041
# env:
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: "CI - Test Features"
22
on:
3-
push:
4-
pull_request:
3+
workflow_call:
54

65
jobs:
76
test-autogenerated:
@@ -20,7 +19,7 @@ jobs:
2019
- name: "Install latest devcontainer CLI"
2120
run: |
2221
npm install -g @devcontainers/cli
23-
mkdir -p ~/.config/devcontainer_rc
22+
mkdir -p ~/.config/bash-config
2423
2524
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
2625
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "Validate devcontainer-feature.json files"
22
on:
3-
pull_request:
3+
workflow_call:
44

55
jobs:
66
validate:

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
check:
9+
uses: ./.github/workflows/_check.yml
10+
11+
validate:
12+
needs: check
13+
if: needs.check.outputs.branch-pr == ''
14+
uses: ./.github/workflows/_validate.yml
15+
16+
test:
17+
needs: check
18+
if: needs.check.outputs.branch-pr == ''
19+
uses: ./.github/workflows/_test.yml
20+
21+
release:
22+
if: github.ref_type == 'tag'
23+
needs: test
24+
uses: ./.github/workflows/_release.yml
25+
permissions:
26+
contents: write
27+
packages: write
28+

0 commit comments

Comments
 (0)