Skip to content

Commit

Permalink
chore: execute workflow again (#52)
Browse files Browse the repository at this point in the history
* chore: Execute workflow again

* fix: fix needs job name

* ci: Test 1

* ci: Test 2

* ci: Test 3

* ci: Test 4

* ci: Test 5

* ci: Test 6

* ci: Test 7

* ci: Test 8

* ci: Test 9

* ci: Test 10

* ci: fix test.yml

* ci: fix test.yml retry job

* ci: fix test.yml retry job

* ci: fix test.yml retry job

* ci: fix test.yml retry job

* ci: debug retry job

* ci: fix test.yml retry job

* ci: fix test.yml workflow_id

* ci: fix test.yml retry job ref

* ci: fix test.yml retry job ref

* ci: remove GITHUB_TOKEN

* ci: fix syntax error

* ci: add triger workflow_dispatch

* ci: fix test.yml retry job workflow_id

* ci: add step rerun workflow

* ci: add --failed option

* ci: fix test.yml run_id

* ci: add comment out

* ci: remove commentout

* ci: add actions/checkout@v2

* ci: fix run_id

* ci: add rerun_workflow.yml

* ci: add github.event.workflow_run.conclusion

* ci: rename file

* ci: rename file

* ci: test triger

* ci: test trigger

* ci: test trigger

* ci: test trigger

* ci: trigger test

* ci: test trigger

* ci: test trigger

* ci: test trigger

* ci:test trriger

* ci: test trigger

* ci: test trigger

* ci: test trigger

* ci: test trigger

* ci: fix test.yml rerun job

* ci: Change initial letter from lowercase to uppercase
  • Loading branch information
uhobeike authored May 14, 2024
1 parent b1d5801 commit 26f35f3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/rerun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: rerun-test

on:
workflow_dispatch:

jobs:
retry:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Rerun 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)
49 changes: 46 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ on:
paths-ignore:
- '**.md'

env:
RETRY-TEST-NUM: 10

jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 5
container: osrf/ros:humble-desktop-full
steps:
- uses: actions/checkout@v2
- name: apt update install
- name: Apt update install
run: |
sudo apt update -y
sudo apt install -y \
Expand All @@ -28,7 +32,7 @@ jobs:
ros-$ROS_DISTRO-navigation2 \
ros-$ROS_DISTRO-nav2-bringup \
ros-$ROS_DISTRO-turtlebot3-gazebo
- name: build
- name: Build
run: |
mkdir -p /root/ros2_ws/src/emcl2_ros2/
rsync -av ./ /root/ros2_ws/src/emcl2_ros2/
Expand All @@ -38,8 +42,47 @@ jobs:
rosdep install -i -y --from-path src --rosdistro $ROS_DISTRO
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
shell: bash
- name: exec
- name: Exec
run: |
source /root/ros2_ws/install/setup.bash
ros2 run emcl2 test.bash
shell: bash

retry:
runs-on: ubuntu-22.04
needs: test
if: ${{ always() && needs.test.result == 'failure' }}
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
async function run() {
const { owner, repo } = context.repo;
const workflow_id = 'rerun.yml';
const ref = 'chore/execute-workflow-again';
const run_id = context.runId;
try {
const workflow_run = await github.rest.actions.getWorkflowRun({
owner,
repo,
run_id
});
if (workflow_run.data.run_attempt < ${{ env.RETRY-TEST-NUM }}) {
console.log('Triggering workflow dispatch...');
await github.rest.actions.createWorkflowDispatch({
owner,
repo,
workflow_id,
ref
});
} else {
console.log('Conditions not met for re-dispatch.');
}
} catch (error) {
console.error('Failed to fetch workflow run or dispatch:', error);
}
}
run();

0 comments on commit 26f35f3

Please sign in to comment.