Skip to content

Commit

Permalink
hotfix: support cmake 3.20, add workflow modify checker. (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-matsuzawa authored Apr 6, 2021
1 parent 721d2fe commit 9954c51
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/create_release-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ jobs:
- name: cmake-build
run: |
cd cfd-sys/cfd-cmake
cmake -S . -B build
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SHARED=${{ matrix.shared }} -DENABLE_CAPI=on -DENABLE_TESTS=off -DENABLE_JS_WRAPPER=off --build build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_SHARED=${{ matrix.shared }} -DENABLE_CAPI=on -DENABLE_TESTS=off -DENABLE_JS_WRAPPER=off
cmake --build build --parallel 2 --config Release
cd ../..
timeout-minutes: 20
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/workflow_modify_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: workflow modify checker

# This file is is check the workflow modification on the pull request.
# If this workflow is set to work, it will forcibly cancel all workflows when any workflow changes are made.
# To get this workflow working, configure the following settings:
# 1. Push this file to the default branch.
# 2. Add issue label 'update CI'.
# 3. Set github secrets 'CANCEL_WORKFLOW_TOKEN'. (Token can cancel the repository workflow.)
#
# If you want to modify any of the workflow files, set the Pull Request label to 'update CI'.
# Then re-run the canceled workflow.

on:
pull_request_target:
types: [opened, reopened, synchronize, labeled]
paths:
'.github/workflows/**'

jobs:
check-actions:
name: check actions
runs-on: ubuntu-20.04

steps:
- name: check secret
id: check_secret
run: |
if [[ -n '${{secrets.CANCEL_WORKFLOW_TOKEN}}' ]]; then
echo "::set-output name=exist_secret::true"
else
echo "::set-output name=exist_secret::false"
fi
- if: contains(github.event.pull_request.labels.*.name, 'update CI') != true && steps.check_secret.outputs.exist_secret == 'true'
name: wait 20 sec
run: sleep 20
- if: contains(github.event.pull_request.labels.*.name, 'update CI') != true && steps.check_secret.outputs.exist_secret == 'true'
name: cancel workflows
id: cancel_workflow
uses: actions/github-script@v3
with:
github-token: ${{ secrets.CANCEL_WORKFLOW_TOKEN }}
script: |
const creator = context.payload.sender.login
const opts1 = github.actions.listWorkflowRunsForRepo.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
event: 'pull_request',
status: 'queued'
})
const queuedWorkflows = await github.paginate(opts1)
const opts2 = github.actions.listWorkflowRunsForRepo.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
event: 'pull_request',
status: 'in_progress'
})
const inProgressWorkflows = await github.paginate(opts2)
const workflows = queuedWorkflows.concat(inProgressWorkflows)
//console.log(workflows);
for (const workflow of workflows) {
if (workflow.run_number == context.runNumber) continue
await github.actions.cancelWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: workflow.id
})
console.log(`cancel: ${workflow.name} (${workflow.id}),`,
`path:${workflow.head_repository.full_name}/tree/${workflow.head_branch}`);
}
throw new Error('Change workflow file. please set label "update CI".')
- if: success()
run: echo "enabled editing workflow."

0 comments on commit 9954c51

Please sign in to comment.