Skip to content

Commit

Permalink
feat(autotool-plugin-github): do not run github page related steps wh…
Browse files Browse the repository at this point in the history
…en its not enabled
  • Loading branch information
AlexAegis committed May 5, 2024
1 parent e4ef258 commit d114dbe
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 32 deletions.
57 changes: 41 additions & 16 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ concurrency:
cancel-in-progress: true

jobs:
collect:
runs-on: ubuntu-latest
outputs:
non_published_packages:
${{ steps.collect_packages.outputs.non_published_packages }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
lfs: true
- name: collect public packages
id: collect_packages
uses: AlexAegis/collect-public-packages@v2
check-pages:
runs-on: ubuntu-latest
outputs:
pages_enabled: ${{ steps.check_pages.outputs.is_enabled }}
steps:
- name: check if github pages is enabled
id: check_pages
uses: AlexAegis/check-github-pages@v1
lint:
name: lint:${{ matrix.lint-kind }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -67,6 +90,8 @@ jobs:
typedoc:
name: typedoc
runs-on: ubuntu-latest
needs: [check-pages]
if: needs.check-pages.outputs.pages_enabled == 'true'
strategy:
matrix:
node-version: [20.x]
Expand Down Expand Up @@ -112,6 +137,7 @@ jobs:
run: pnpm run typedoc
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -121,13 +147,15 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request'
- name: upload artifact
uses: actions/upload-pages-artifact@v3
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -137,6 +165,8 @@ jobs:
vitepress:
name: vitepress
runs-on: ubuntu-latest
needs: [check-pages]
if: needs.check-pages.outputs.pages_enabled == 'true'
strategy:
matrix:
node-version: [20.x]
Expand Down Expand Up @@ -182,6 +212,7 @@ jobs:
run: pnpm run vitepress
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -191,13 +222,15 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request'
- name: upload artifact
uses: actions/upload-pages-artifact@v3
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -207,6 +240,7 @@ jobs:
test:
name: test
runs-on: ubuntu-latest
needs: [check-pages]
strategy:
matrix:
node-version: [20.x]
Expand Down Expand Up @@ -256,6 +290,7 @@ jobs:
directory: coverage
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -265,13 +300,15 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request'
- name: upload artifact
uses: actions/upload-pages-artifact@v3
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand Down Expand Up @@ -324,6 +361,7 @@ jobs:
run: pnpm run publint
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'build' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -333,6 +371,7 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'build' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -351,36 +390,22 @@ jobs:
if: |
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request' &&
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR && (
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'build' ||
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' ||
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' ||
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress'
)
runs-on: ubuntu-latest
needs: [build, test, lint, typedoc, vitepress]
needs: [build, test, lint, typedoc, vitepress, check-pages]
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: deploy to github pages
uses: actions/deploy-pages@v4
id: deployment
collect:
runs-on: ubuntu-latest
outputs:
non_published_packages:
${{ steps.collect_packages.outputs.non_published_packages }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
lfs: true
- name: collect public packages
id: collect_packages
uses: AlexAegis/collect-public-packages@v2
release:
name: |
release ${{ matrix.package.package_name }}@${{ matrix.package.package_version }}
Expand Down
57 changes: 41 additions & 16 deletions packages/autotool-plugin-github/static/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ concurrency:
cancel-in-progress: true

jobs:
collect:
runs-on: ubuntu-latest
outputs:
non_published_packages:
${{ steps.collect_packages.outputs.non_published_packages }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
lfs: true
- name: collect public packages
id: collect_packages
uses: AlexAegis/collect-public-packages@v2
check-pages:
runs-on: ubuntu-latest
outputs:
pages_enabled: ${{ steps.check_pages.outputs.is_enabled }}
steps:
- name: check if github pages is enabled
id: check_pages
uses: AlexAegis/check-github-pages@v1
lint:
name: lint:${{ matrix.lint-kind }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -67,6 +90,8 @@ jobs:
typedoc:
name: typedoc
runs-on: ubuntu-latest
needs: [check-pages]
if: needs.check-pages.outputs.pages_enabled == 'true'
strategy:
matrix:
node-version: [20.x]
Expand Down Expand Up @@ -112,6 +137,7 @@ jobs:
run: pnpm run typedoc
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -121,13 +147,15 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request'
- name: upload artifact
uses: actions/upload-pages-artifact@v3
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -137,6 +165,8 @@ jobs:
vitepress:
name: vitepress
runs-on: ubuntu-latest
needs: [check-pages]
if: needs.check-pages.outputs.pages_enabled == 'true'
strategy:
matrix:
node-version: [20.x]
Expand Down Expand Up @@ -182,6 +212,7 @@ jobs:
run: pnpm run vitepress
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -191,13 +222,15 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request'
- name: upload artifact
uses: actions/upload-pages-artifact@v3
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -207,6 +240,7 @@ jobs:
test:
name: test
runs-on: ubuntu-latest
needs: [check-pages]
strategy:
matrix:
node-version: [20.x]
Expand Down Expand Up @@ -256,6 +290,7 @@ jobs:
directory: coverage
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -265,13 +300,15 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request'
- name: upload artifact
uses: actions/upload-pages-artifact@v3
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand Down Expand Up @@ -324,6 +361,7 @@ jobs:
run: pnpm run publint
- name: prepare pages (use index.html as 404.html)
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'build' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -333,6 +371,7 @@ jobs:
- name: setup pages
uses: actions/configure-pages@v4
if: |
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'build' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR != '' &&
github.ref_name == github.event.repository.default_branch &&
Expand All @@ -351,36 +390,22 @@ jobs:
if: |
github.ref_name == github.event.repository.default_branch &&
github.event_name != 'pull_request' &&
needs.check-pages.outputs.pages_enabled == 'true' &&
vars.PAGES_DEPLOY_ARTIFACT_DIR && (
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'build' ||
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'test' ||
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'typedoc' ||
vars.PAGES_DEPLOY_ARTIFACT_BUILDING_JOB == 'vitepress'
)
runs-on: ubuntu-latest
needs: [build, test, lint, typedoc, vitepress]
needs: [build, test, lint, typedoc, vitepress, check-pages]
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: deploy to github pages
uses: actions/deploy-pages@v4
id: deployment
collect:
runs-on: ubuntu-latest
outputs:
non_published_packages:
${{ steps.collect_packages.outputs.non_published_packages }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
lfs: true
- name: collect public packages
id: collect_packages
uses: AlexAegis/collect-public-packages@v2
release:
name: |
release ${{ matrix.package.package_name }}@${{ matrix.package.package_version }}
Expand Down

0 comments on commit d114dbe

Please sign in to comment.