From 546aeae7180f5bc0a290db2b2a0de84e419e0af2 Mon Sep 17 00:00:00 2001 From: nkdui Date: Sun, 19 Apr 2026 23:04:40 +0700 Subject: [PATCH] update validate, test, release workflows --- .github/workflows/release.yaml | 26 ++++++++++++++++++-- .github/workflows/test.yaml | 44 ++++++++++++++++++++++++++++++---- .github/workflows/validate.yml | 4 ++-- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 57572c7..1018577 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,10 +1,32 @@ -name: "Release dev container features & Generate Documentation" +name: "Devcontainer publish" on: + workflow_run: + workflows: ["Devcontainer test"] + types: [completed] + branches: ["main"] workflow_dispatch: jobs: + check-test: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch' }} + outputs: + should_run: ${{ steps.check.outputs.should_run }} + steps: + - id: check + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "should_run=true" >> $GITHUB_OUTPUT + elif [ "${{ github.event.workflow_run.conclusion }}" = "success" ]; then + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "Test workflow did not succeed. Skipping release." + echo "should_run=false" >> $GITHUB_OUTPUT + fi + deploy: - if: ${{ github.ref == 'refs/heads/main' }} + needs: check-test + if: needs.check-test.outputs.should_run == 'true' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest permissions: contents: write diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3f62171..8d856e2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,13 +1,43 @@ -name: "CI - Test Features" +name: "Devcontainer test" on: - push: - branches: - - main - pull_request: + workflow_run: + workflows: ["Devcontainer validate"] + types: [completed] workflow_dispatch: jobs: + check-validate: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch' }} + outputs: + should_run: ${{ steps.check.outputs.should_run }} + steps: + - id: check + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "should_run=true" >> $GITHUB_OUTPUT + elif [ "${{ github.event.workflow_run.event }}" = "pull_request" ]; then + if [ "${{ github.event.workflow_run.conclusion }}" = "success" ]; then + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "Validate workflow did not succeed. Skipping tests." + echo "should_run=false" >> $GITHUB_OUTPUT + fi + elif [ "${{ github.event.workflow_run.head_branch }}" = "main" ]; then + if [ "${{ github.event.workflow_run.conclusion }}" = "success" ]; then + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "Validate workflow did not succeed. Skipping tests." + echo "should_run=false" >> $GITHUB_OUTPUT + fi + else + echo "Not a PR or main branch push. Skipping tests." + echo "should_run=false" >> $GITHUB_OUTPUT + fi + test-autogenerated: + needs: check-validate + if: needs.check-validate.outputs.should_run == 'true' runs-on: ubuntu-latest continue-on-error: true strategy: @@ -29,6 +59,8 @@ jobs: run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . test-scenarios: + needs: check-validate + if: needs.check-validate.outputs.should_run == 'true' runs-on: ubuntu-latest continue-on-error: true strategy: @@ -45,6 +77,8 @@ jobs: run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated . test-global: + needs: check-validate + if: needs.check-validate.outputs.should_run == 'true' runs-on: ubuntu-latest continue-on-error: true steps: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 863418e..0b4f417 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,6 +1,6 @@ -name: "Validate devcontainer-feature.json files" +name: "Devcontainer validate" on: - workflow_dispatch: + push: pull_request: jobs: