Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,28 @@ jobs:
run: env

- name: "Cleanup PR"
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.TEST_PULL_TOKEN }}
run: |
pull="$(gh api /repos/${{ env.repository }}/pulls \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--jq '.[0].number'
number="$(gh pr list \
--repo "${{ env.repository }}" --json number \
--template '{{if gt (len .) 0}}{{(index . 0).number}}{{end}}' \
)"
[ -z "${pull}" ] && exit 0
echo "Closing PR: ${pull}"
gh api --method PATCH "/repos/${{ env.repository }}/pulls/${pull}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f "state=closed" --silent
echo "Waiting 3 Seconds..."
sleep 3
if [ -n "${number}" ];then
echo "Closing Pull Request: ${number}"
gh pr close --repo "${{ env.repository }}" "${number}"
echo "Waiting 3 Seconds..."
sleep 3
else
echo "No PR's found: ${{ github.server_url }}/${{ env.repository }}/pulls"
fi

- name: "Test Local Action"
id: test
uses: ./
with:
repository: ${{ env.repository }}
head: test1
#base: master
#title: Ralf Broke It
#body: Broken ${{ github.run_number }} times.
token: ${{ secrets.TEST_PULL_TOKEN }}

- name: "Validate Outputs"
Expand Down
11 changes: 7 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31528,11 +31528,12 @@ class GitHub {
this.octokit = githubExports.getOctokit(token);
}
async createPull(data) {
console.log('createPull:', data);
coreExports.debug(`createPull: ${JSON.stringify(data)}`);
const response = await this.octokit.rest.pulls.create(data);
return response.data;
}
async getRepository(data) {
coreExports.debug(`getRepository: ${JSON.stringify(data)}`);
const response = await this.octokit.rest.repos.get(data);
return response.data;
}
Expand Down Expand Up @@ -31574,13 +31575,15 @@ async function main() {
const repository = await api.getRepository(data);
data.base = repository.default_branch;
}
console.log('data:', data);
coreExports.startGroup('Request data');
console.log(data);
coreExports.endGroup();
coreExports.info('⌛ Creating Pull Request...');
const pull = await api.createPull(data);
coreExports.startGroup('pull');
coreExports.startGroup('Response data');
console.log(JSON.stringify(pull, null, 2));
coreExports.endGroup();
coreExports.info(`🚀 Pull Request Created: ${pull.number}`);
coreExports.info(`🚀 Pull Request Created: ${pull.html_url}`);
if (inputs.summary) {
coreExports.info('📝 Writing Job Summary');
try {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-typescript": "^12.3.0",
"@types/node": "^25.0.3",
"@types/node": "^25.0.5",
"@typescript-eslint/eslint-plugin": "^8.52.0",
"@typescript-eslint/parser": "^8.52.0",
"eslint": "^9.39.2",
Expand Down
4 changes: 3 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types.js'

Expand All @@ -14,12 +15,13 @@ export class GitHub {
}

async createPull(data: PullRequest) {
console.log('createPull:', data)
core.debug(`createPull: ${JSON.stringify(data)}`)
const response = await this.octokit.rest.pulls.create(data)
return response.data
}

async getRepository(data: { owner: string; repo: string }) {
core.debug(`getRepository: ${JSON.stringify(data)}`)
const response = await this.octokit.rest.repos.get(data)
return response.data
}
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ async function main() {
const repository = await api.getRepository(data)
data.base = repository.default_branch
}
console.log('data:', data)
core.startGroup('Request data')
console.log(data)
core.endGroup() // data

// Processing
core.info('⌛ Creating Pull Request...')
const pull = await api.createPull(data)
core.startGroup('pull')
core.startGroup('Response data')
console.log(JSON.stringify(pull, null, 2))
core.endGroup() // pull
core.info(`🚀 Pull Request Created: ${pull.number}`)
core.info(`🚀 Pull Request Created: ${pull.html_url}`)

// Summary
if (inputs.summary) {
Expand Down
Loading