-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write github actions needed for auto closing issues opened beyond core (
#639)
- Loading branch information
1 parent
506a41e
commit 9943f16
Showing
6 changed files
with
87 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: 'Close issue when opened' | ||
description: 'Closes a newly opened issue, tags it and puts it in the proper column in Smackore project board.' | ||
inputs: | ||
GITHUB_TOKEN: | ||
description: 'GitHub token' | ||
required: true | ||
ISSUE_URL: | ||
description: 'Issue URL' | ||
required: true | ||
ISSUE_NUMBER: | ||
description: 'Issue number' | ||
required: true | ||
REPOSITORY: | ||
description: 'Repository' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Setup Elixir | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: '26.1' | ||
elixir-version: '1.15.6' | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Create ticket and close issue | ||
run: | | ||
export PROJECT_NUMBER=19 | ||
export PROJECT_ID=PVT_kwDOAYE_z84AWEIB | ||
export STATUS_FIELD_ID=PVTSSF_lADOAYE_z84AWEIBzgOGd1k | ||
export TARGET_COLUMN_ID=fa223107 | ||
export CORE_URL=https://github.com/membraneframework/membrane_core | ||
export ISSUE_CLOSE_COMMENT="Issues related to $REPOSITORY are stored in [membrane_core]($CORE_URL), so we close this issue here and we encourage you to open it [there]($CORE_URL) with labels describing, which repositories relate to the issue." | ||
gh issue edit $ISSUE_URL --add-project "Smackore" --add-label closed-by-membrane-bot | ||
sleep 10 | ||
export TICKET_ID=$(gh project item-list $PROJECT_NUMBER --owner membraneframework --format json --limit 10000000 | elixir get_ticket_id.exs "$ISSUE_URL" | awk '/TICKET_ID/{print $2}') | ||
gh issue close $ISSUE_URL --comment "$ISSUE_CLOSE_COMMENT" --reason "not planned" | ||
sleep 10 | ||
gh project item-edit --id $TICKET_ID --field-id $STATUS_FIELD_ID --project-id $PROJECT_ID --single-select-option-id $TARGET_COLUMN_ID | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} | ||
ISSUE_URL: ${{ inputs.ISSUE_URL }} | ||
ISSUE_NUMBER: ${{ inputs.ISSUE_NUMBER }} | ||
REPOSITORY: ${{ inputs.REPOSITORY }} | ||
shell: bash |
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,14 @@ | ||
name: 'Create label' | ||
description: 'Creates a label closed-by-membrane-bot, if it does not exist.' | ||
inputs: | ||
GITHUB_TOKEN: | ||
description: 'GitHub token' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- run: | | ||
gh label create closed-by-membrane-bot --description "Automatically closed by Membrane bot" --color EB3467 || true | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} | ||
shell: bash |
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ jobs: | |
env: | ||
GH_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
run: | | ||
elixir update_packages_list.exs | ||
elixir scripts/update_packages_list.exs | ||
git config user.name 'Membrane Bot' | ||
git config user.email '[email protected]' | ||
git checkout -B auto-update-packages-list | ||
|
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,23 @@ | ||
# This script is used by .github/actions/close_issue/action.yml and it shouldn't be used in any other places. | ||
|
||
# It expects: | ||
# - output from `$ gh project item-list <project_id> --owner <owner> --format json --limit <limit>` command | ||
# on standard input | ||
# - URL of issue, that corresponds to one of the tickets included in the JSON data returned from the command | ||
# above. This URL should be passed as an argument in argv | ||
# And prints `TICKET_ID <id>` on standard output, where `<id>` is id of a project item corresponding to the | ||
# issue with the specified URL. Note, that beyond this, stdout can also contain some logs from `Mix.install/1`, | ||
# e.g. `Resolving Hex dependencies...`. | ||
|
||
Mix.install(json: "~> 1.4.1") | ||
|
||
[issue_url] = System.argv() | ||
|
||
:ok = | ||
IO.read(:stdio, :eof) | ||
|> JSON.decode!() | ||
|> Map.get("items") | ||
|> Enum.find(&(&1["content"]["url"] == issue_url)) | ||
|> Map.get("id") | ||
|> then(&"\nTICKET_ID #{&1}\n") | ||
|> IO.puts() |
File renamed without changes.