Skip to content

Instantly share code, notes, and snippets.

@bugcy013
Last active September 7, 2022 03:31
Show Gist options
  • Save bugcy013/d51fa180b08260adf13957975ce02b36 to your computer and use it in GitHub Desktop.
Save bugcy013/d51fa180b08260adf13957975ce02b36 to your computer and use it in GitHub Desktop.
# This is a basic workflow to help you get started with Actions
name: Workflow-1
# Controls when the workflow will run
on:
workflow_dispatch:
inputs:
workflow2_name:
description: 'Workflow2 Name for Triggering'
required: true
default: 'workflow2'
workflow2_github_account:
description: 'GitHub Account Owner'
required: true
default: 'sumitraj0103'
workflow2_repo_github:
description: 'GitHub Repository Name'
required: true
default: 'Letsdevops'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
pat_token: ${{ secrets.Workflow2_PAT_TOKEN_GITHUB }}
payload_Baseline_Number: "BSL_001"
payload_Baseline_Revision: "zsfdgsdbgngffdwdx1dxvv2"
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8 #install the python needed
- name: Install dependencies
run: |
cd "$GITHUB_WORKSPACE/Deployment-Scripts/"
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Trigger the Workflow
run: |
cd "$GITHUB_WORKSPACE/Deployment-Scripts/"
python3 $GITHUB_WORKSPACE/Deployment-Scripts/workflow_trigger.py ${{ env.Workflow2_PAT_TOKEN_GITHUB }} ${{ github.event.inputs.workflow2_github_account}} ${{ github.event.inputs.workflow2_repo_github}} ${{ github.event.inputs.workflow2_name}} ${{ env.payload_Baseline_Number }} ${{ env.payload_Baseline_Revision }}
# This is a basic workflow to help you get started with Actions
name: Workflow2
# Controls when the workflow will run
on:
repository_dispatch:
types: [Workflow2]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
baselineTag: ${{ github.event.client_payload.baselinetag }}
revision_number: ${{ github.event.client_payload.revision_number }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
echo $baselineTag
echo $revision_number
import openpyxl
import os
import requests
import sys
#pip install --upgrade pandas
import os
import requests
import sys
TOKEN= str(sys.argv[1])
OWNER= str(sys.argv[2])
REPO= str(sys.argv[3])
Workflow_Name= str(sys.argv[4])
pl_Baseline_Number= str(sys.argv[5])
pl_Baseline_Revision = str(sys.argv[6])
def trigger_workflow(Workflow_Name,pl_Baseline_Number,pl_Baseline_Revision):
headers = {
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {TOKEN}",
}
data = {
"event_type": Workflow_Name,
"client_payload": {
'baselinetag': pl_Baseline_Number,
'revision_number': pl_Baseline_Revision
}
}
requests.post(
f"https://api.github.com/repos/{OWNER}/{REPO}/dispatches",
json=data,
headers=headers
)
trigger_workflow(Workflow_Name,pl_Baseline_Number,pl_Baseline_Revision)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment