Skip to content

Commit

Permalink
adjust custom action
Browse files Browse the repository at this point in the history
  • Loading branch information
HarriPra committed Mar 6, 2024
1 parent 53a7605 commit 1ce02fe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/actions/repo-dispatch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inputs:
event-type:
description: 'A custom event type for repository Dispatch'
required: true
clientPayload:
description: 'Payload to send with the dispatch event'
required: false

runs:
using: 'node12'
Expand Down
10 changes: 7 additions & 3 deletions .github/actions/repo-dispatch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ const core = require('@actions/core');
const github = require('@actions/github');

// The main function that wraps the action logic
async function run() {
async function run() {//change function name
try {
// Get inputs defined in action.yml using the core library
const token = core.getInput('repo-token', { required: true });
const targetRepo = core.getInput('target-repository', { required: true });
const eventType = core.getInput('event-type', { required: true });
const clientPayload = core.getInput('clientPayload')

// Split the target repository string into owner and repository name
const [owner, repo] = targetRepo.split('/');
Expand All @@ -21,7 +22,7 @@ async function run() {
repo, // Repository name
event_type: eventType, // Custom event type to trigger the workflow
// Additional data to send with the event (optional)
client_payload: { ref: github.context.ref, sha: github.context.sha },
client_payload: JSON.parse(clientPayload || {}),
});

// Log a success message to the console
Expand All @@ -33,4 +34,7 @@ async function run() {
}

// Execute the run function
run();
run();

//make my own workflow
//
19 changes: 19 additions & 0 deletions .github/workflows/cross-repo-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Trigger Deployment Workflow in CareObra

on:
pull_request:
types: [closed] #doublechec this meaning
branches:
- feature/LADO-1108-GenerateAutomaticChange

jobs:
trigger-deployment:
runs-on: ubuntu-latest
if: github.event.pull_request == true
steps:
- name: Trigger deployment in another repo
uses: ./.github/actions/repo-dispatch
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: UKHSA-Internal/hpod-ukhsa-generate-webform-url-citizen # Replace target repository's name
event-type: trigger-deployment # This is a custom event type we listen for in deployment.yml

0 comments on commit 1ce02fe

Please sign in to comment.