Skip to content

Commit

Permalink
Adding manual workflow trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoreliovlabs committed Aug 30, 2024
1 parent a679f87 commit 38f938c
Showing 1 changed file with 35 additions and 48 deletions.
83 changes: 35 additions & 48 deletions .github/workflows/rit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,66 @@ on:
branches:
- "master"
- "*-rc"
pull_request:
types: [opened, reopened, synchronize]
branches:
- "**"
issue_comment:
types:
- created
- edited
workflow_dispatch:
inputs:
rit-branch:
description: 'Branch for Rootstock Integration Tests'
required: false
default: 'main'
powpeg-branch:
description: 'Branch for PowPeg Node'
required: false
default: 'master'

jobs:
rootstock-integration-tests:
name: Rootstock Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Set Branch Variables
id: set-branch-variables
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
# Determine branch name for push event
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "RSKJ_BRANCH=master" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == refs/heads/*-rc ]]; then
branch_name="${{ github.ref#refs/heads/}}"
echo "RSKJ_BRANCH=$branch_name" >> $GITHUB_ENV
fi
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Use the PR branch name for pull request events
echo "RSKJ_BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
fi
echo "RIT_BRANCH=${{ github.event.inputs.rit-branch }}" >> $GITHUB_ENV
echo "POWPEG_BRANCH=${{ github.event.inputs.powpeg-branch }}" >> $GITHUB_ENV
echo "RSKJ_BRANCH=${{ env.RSKJ_BRANCH }}"
echo "RIT_BRANCH=${{ env.RIT_BRANCH }}"
echo "POWPEG_BRANCH=${{ env.POWPEG_BRANCH }}"
- name: Checkout rskj Repository
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
repository: rsksmart/rskj
ref: ${{ github.event.pull_request.head.ref }}
ref: ${{ env.RSKJ_BRANCH }}
fetch-depth: 1

- name: Get PR Description
if: github.event_name == 'pull_request'
id: get-pr-description
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PR_DESC=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER")
echo "PR Description: $PR_DESC"
rskj_branch=$(echo "$PR_DESC" | grep -Po '(?<=RSKj Branch: rskj:)\w+' || echo "master")
fed_branch=$(echo "$PR_DESC" | grep -Po '(?<=PowPeg Node Branch: fed:)\w+' || echo "master")
rit_branch=$(echo "$PR_DESC" | grep -Po '(?<=Rootstock Integration Tests Branch: rit:)\w+' || echo "main")
echo "RSKJ_BRANCH=$rskj_branch" >> $GITHUB_ENV
echo "FED_BRANCH=$fed_branch" >> $GITHUB_ENV
echo "RIT_BRANCH=$rit_branch" >> $GITHUB_ENV
echo "{\"rskj_branch\": \"$rskj_branch\", \"fed_branch\": \"$fed_branch\", \"rit_branch\": \"$rit_branch\"}" > debug-values.json
- name: Test jq Installation
run: |
echo '{"key":"value"}' | jq '.key'
cat debug-values.json
echo "RSKJ Branch: $(jq -r '.rskj_branch' debug-values.json)"
echo "FED Branch: $(jq -r '.fed_branch' debug-values.json)"
echo "RIT Branch: $(jq -r '.rit_branch' debug-values.json)"
- name: Checkout Rootstock Integration Tests Repository
uses: actions/checkout@v4
with:
repository: rsksmart/rootstock-integration-tests
ref: ${{ env.RIT_BRANCH }}
fetch-depth: 0

- name: Check Comment Condition
run: |
echo "Evaluating condition..."
if [[ "${{ github.event_name }}" == "issue_comment" && "${{ github.event.comment.body }}" == *"/pipeline:run"* ]]; then
echo "Condition met: Pipeline run command detected in comment."
else
echo "Condition not met: Comment body is '${{ github.event.comment.body }}'"
fi
- name: Run Rootstock Integration Tests
if: github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/pipeline:run'))
uses: rsksmart/rootstock-integration-tests@v1
with:
rskj-branch: ${{ env.RSKJ_BRANCH }}
powpeg-node-branch: ${{ env.FED_BRANCH }}
powpeg-node-branch: ${{ env.POWPEG_BRANCH }}

- name: Notify on Status
run: echo "Rootstock Integration Tests pipeline triggered"

0 comments on commit 38f938c

Please sign in to comment.