-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update standpoints action with git helpers and check for diffe…
…rences before committing
- Loading branch information
Showing
5 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
name: Update Standpoints | ||
description: Script that updates the party standpoints | ||
inputs: | ||
github-token: | ||
description: GitHub token | ||
required: true | ||
runs: | ||
using: node20 | ||
main: dist/index.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import core from "@actions/core"; | ||
import github from "@actions/github"; | ||
|
||
const { context } = github; | ||
|
||
const token = core.getInput("github-token"); | ||
const client = github.getOctokit(token); | ||
|
||
/** | ||
* | ||
* @param {string} title | ||
* @param {string} body | ||
* @param {string} head | ||
* @param {string} base | ||
*/ | ||
export async function createPullRequest(title, body, head, base = "main") { | ||
const { data } = await client.rest.pulls.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: title, | ||
body, | ||
head, | ||
base, | ||
}); | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
// @ts-check | ||
import github from "@actions/github"; | ||
|
||
console.log("Hello from update-standpoints!"); | ||
import { add, checkHasDiff, checkout, commit, push } from "./git-helper.mjs"; | ||
|
||
const hasDiff = await checkHasDiff(); | ||
|
||
if (!hasDiff) { | ||
console.log("No changes detected, exiting..."); | ||
process.exit(0); | ||
} | ||
|
||
const runId = github.context.runId; | ||
const branchName = `update-standpoints-${runId}`; | ||
|
||
// Checkout and push changes | ||
await checkout(branchName, "main"); | ||
await add(); | ||
await commit("Update standpoints"); | ||
await push(); |