Skip to content

Commit

Permalink
Merge pull request #27 from gabrielogregorio/dev
Browse files Browse the repository at this point in the history
fix: create discussions
  • Loading branch information
gabrielogregorio authored Feb 25, 2024
2 parents 07c2fdb + a92e943 commit 8bdbc42
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
ref: main

- name: create tag and release
uses: gabrielogregorio/create-tag-and-release@v1.0.1
uses: gabrielogregorio/create-tag-and-release@v2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -59,18 +59,16 @@ In the `set config tag and release` step, various information is obtained, such
```yml
name: create tag and release on merge pr
# when there is a push event in main or when a pull request is closed pointing to main
# when a pull request is closed pointing to main
on:
push:
branches: [main]
pull_request:
types: [closed]
branches: [main]
jobs:
create-release:
# If there is a push event pointing to main OR if there is a pull request event being merged
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
# if there is a pull request event being merged
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: checkout
Expand Down Expand Up @@ -105,7 +103,7 @@ jobs:
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
- name: create tag and release
uses: gabrielogregorio/create-tag-and-release@v1.0.1
uses: gabrielogregorio/create-tag-and-release@v2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -118,9 +116,6 @@ jobs:
draft: false
prerelease: false
# This is in case you want your release to be published as a discussion, in which case it will be published in the "Announcements" discussion
discussion_category_name: 'Announcements'
```
### Understanding Input Settings

Expand Down
17 changes: 4 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32989,19 +32989,10 @@ const createTagAndRelease = (inputs) => __awaiter(void 0, void 0, void 0, functi
var _a;
console.log('create tag and release with inputs', JSON.stringify(inputs));
const octokit = connectOctokit();
const response = yield octokit.request(`POST /repos/${inputs.owner}/${inputs.repo}/releases`, {
owner: inputs.owner,
repo: inputs.repo,
tag_name: inputs.tag_name,
target_commitish: inputs.target_commitish,
name: inputs.release_name,
body: inputs.body,
draft: inputs.draft,
prerelease: inputs.prerelease,
discussion_category_name: inputs.discussion_category_name,
generate_release_notes: inputs.generate_release_notes,
make_latest: inputs.make_latest,
});
const payloadDiscussionCategoryName = inputs.discussion_category_name
? { discussion_category_name: inputs.discussion_category_name }
: {};
const response = yield octokit.request(`POST /repos/${inputs.owner}/${inputs.repo}/releases`, Object.assign(Object.assign({}, payloadDiscussionCategoryName), { owner: inputs.owner, repo: inputs.repo, tag_name: inputs.tag_name, target_commitish: inputs.target_commitish, name: inputs.release_name, body: inputs.body, draft: inputs.draft, prerelease: inputs.prerelease, generate_release_notes: inputs.generate_release_notes, make_latest: inputs.make_latest }));
console.log('tag and release create with success');
const { data } = response || {};
const outputs = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create_tag_and_release",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/createTagAndRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ export const createTagAndRelease = async (inputs: ReleaseInputs) => {
console.log('create tag and release with inputs', JSON.stringify(inputs));
const octokit = connectOctokit();

const payloadDiscussionCategoryName = inputs.discussion_category_name
? { discussion_category_name: inputs.discussion_category_name }
: {};

// https://docs.github.com/pt/rest/releases/releases?apiVersion=2022-11-28#create-a-release
const response = await octokit.request(`POST /repos/${inputs.owner}/${inputs.repo}/releases`, {
...payloadDiscussionCategoryName,
owner: inputs.owner,
repo: inputs.repo,
tag_name: inputs.tag_name,
Expand All @@ -27,7 +32,6 @@ export const createTagAndRelease = async (inputs: ReleaseInputs) => {
body: inputs.body,
draft: inputs.draft,
prerelease: inputs.prerelease,
discussion_category_name: inputs.discussion_category_name,
generate_release_notes: inputs.generate_release_notes,
make_latest: inputs.make_latest,
});
Expand Down

0 comments on commit 8bdbc42

Please sign in to comment.