Skip to content

Commit

Permalink
ci: fix ref if main (#54)
Browse files Browse the repository at this point in the history
* ci: fix ref

* ci: add TEST-TIMEOUT-MIN env variable

* ci: remove env variable

* ci: fix syntax error

* ci: test rerun

* ci: test rerun

* ci: remove commentout

* ci: fix ref if main

* ci: fix ref

* ci: add gh run cancel
  • Loading branch information
uhobeike committed May 14, 2024
1 parent b8c0c06 commit c6a8edb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/rerun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Rerun workflow
- name: Check and rerun or cancel workflow
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run rerun $(gh run list -w test.yml | grep -oE '[0-9]{10}' | head -n 1)
STATUS=$(gh run list -w test.yml | awk 'NR==4 {print $1}')
RUN_ID=$(gh run list -w test.yml | grep -oE '[0-9]{10}' | head -n 1)
if [ "$STATUS" == "completed" ]; then
echo "Job is completed, rerunning..."
gh run rerun $RUN_ID
else
echo "Job is not completed, canceling and rerunning..."
gh run cancel $RUN_ID && gh run rerun $RUN_ID
fi
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
async function run() {
const { owner, repo } = context.repo;
const workflow_id = 'rerun.yml';
const ref = '${{ github.head_ref }}';
const ref = ('${{ github.head_ref }}' === 'main') ? 'main' : '${{ github.head_ref }}';
const run_id = context.runId;
try {
Expand Down

0 comments on commit c6a8edb

Please sign in to comment.