Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate workflow to move cards to done, create discussion and post to slack #2870

Open
wants to merge 203 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
8e53306
TEst #2755
padms Jan 23, 2025
8056a7b
Merge branch 'main' into padms/2755
padms Feb 3, 2025
becf724
Update test-workflow.yaml
padms Feb 3, 2025
a72bcd2
Update test-workflow.yaml
padms Feb 3, 2025
4f21120
⚗️ Fix
padms Feb 3, 2025
dba0679
Update test-workflow.yaml
padms Feb 3, 2025
2cdf550
Update action.yaml
padms Feb 3, 2025
1a11b0a
Update secret
padms Feb 3, 2025
fd8e982
Env
padms Feb 3, 2025
b5530c3
var
padms Feb 3, 2025
827e3a8
See whats in project json
padms Feb 4, 2025
51e58e0
see
padms Feb 4, 2025
2764924
Update action.yaml
padms Feb 4, 2025
5870c7d
Update action.yaml
padms Feb 4, 2025
66e2753
Update test-workflow.yaml
padms Feb 4, 2025
1e3d4de
TEst
padms Feb 4, 2025
ce9573c
Update test-workflow.yaml
padms Feb 4, 2025
5231fb9
Test
padms Feb 4, 2025
f05a957
Update action.yaml
padms Feb 5, 2025
05e91e7
Test
padms Feb 5, 2025
ccf980e
Update action.yaml
padms Feb 5, 2025
712b6dd
Update action.yaml
padms Feb 5, 2025
ceaa589
Update test-workflow.yaml
padms Feb 5, 2025
fdbc933
Update action.yaml
padms Feb 5, 2025
cfb483e
Update action.yaml
padms Feb 5, 2025
67780be
Update action.yaml
padms Feb 5, 2025
5774925
Update action.yaml
padms Feb 5, 2025
24c4fb0
Update action.yaml
padms Feb 5, 2025
0f4b9ac
Update action.yaml
padms Feb 5, 2025
7932ba5
Update action.yaml
padms Feb 5, 2025
279ee25
Update action.yaml
padms Feb 5, 2025
bc26ed0
Update action.yaml
padms Feb 5, 2025
787474e
Update action.yaml
padms Feb 5, 2025
6321b0d
Update action.yaml
padms Feb 5, 2025
3d91153
More progress
padms Feb 5, 2025
fa2b311
Update action.yaml
padms Feb 5, 2025
0d1b64a
Update action.yaml
padms Feb 5, 2025
5c54396
Update action.yaml
padms Feb 5, 2025
68b6175
Update action.yaml
padms Feb 5, 2025
9cbfc46
Update action.yaml
padms Feb 5, 2025
a6c671c
Update action.yaml
padms Feb 5, 2025
ae7d9b3
Update action.yaml
padms Feb 5, 2025
7787a52
Update action.yaml
padms Feb 5, 2025
4c2046f
Update action.yaml
padms Feb 5, 2025
fbb650c
Update action.yaml
padms Feb 5, 2025
1222391
Revert "Update action.yaml"
padms Feb 5, 2025
0672dbe
Update action.yaml
padms Feb 5, 2025
13b5d50
Update action.yaml
padms Feb 5, 2025
ecc7ea4
Update action.yaml
padms Feb 5, 2025
e38a777
Update action.yaml
padms Feb 5, 2025
4934392
Update action.yaml
padms Feb 5, 2025
9fb7ccf
Update action.yaml
padms Feb 5, 2025
0c02e19
Update action.yaml
padms Feb 5, 2025
fa4a395
Revert "Update action.yaml"
padms Feb 5, 2025
767d4a0
Update action.yaml
padms Feb 5, 2025
e344128
Update action.yaml
padms Feb 5, 2025
160d495
Update action.yaml
padms Feb 6, 2025
a492bae
Debug
padms Feb 6, 2025
fd63b51
Update action.yaml
padms Feb 6, 2025
d5f2a0a
Update action.yaml
padms Feb 6, 2025
602b384
Update action.yaml
padms Feb 6, 2025
2d8fcc3
Update action.yaml
padms Feb 6, 2025
f9ab529
Update action.yaml
padms Feb 6, 2025
66aadf6
Update action.yaml
padms Feb 6, 2025
398b0c9
Update action.yaml
padms Feb 6, 2025
cf67a81
Update action.yaml
padms Feb 6, 2025
86e3a3c
Update action.yaml
padms Feb 6, 2025
7f3d7ae
TEst
padms Feb 6, 2025
7897a7a
Test
padms Feb 6, 2025
b00fc0e
Update action.yaml
padms Feb 6, 2025
6c13e22
Update action.yaml
padms Feb 6, 2025
8c9bd98
Update action.yaml
padms Feb 6, 2025
fbbb998
Update action.yaml
padms Feb 6, 2025
2bc02b2
Update action.yaml
padms Feb 6, 2025
87417b3
Update action.yaml
padms Feb 6, 2025
5fe8ac5
Update action.yaml
padms Feb 6, 2025
4bdf140
Update action.yaml
padms Feb 6, 2025
68aa759
Update action.yaml
padms Feb 6, 2025
2ebd9e8
Update action.yaml
padms Feb 6, 2025
e0dc876
Update action.yaml
padms Feb 6, 2025
b047a66
Update action.yaml
padms Feb 6, 2025
8757095
Update action.yaml
padms Feb 6, 2025
dca3e62
Test
padms Feb 21, 2025
fd8fa38
Update action.yaml
padms Feb 21, 2025
91eef64
Update action.yaml
padms Feb 21, 2025
2574543
Update action.yaml
padms Feb 21, 2025
d4f2f67
Update action.yaml
padms Feb 21, 2025
4a641b1
Update action.yaml
padms Feb 21, 2025
ddfd029
Update action.yaml
padms Feb 21, 2025
02e9133
Update action.yaml
padms Feb 21, 2025
510e7fd
Update action.yaml
padms Feb 21, 2025
96ace89
Update action.yaml
padms Feb 21, 2025
571a827
Update action.yaml
padms Feb 21, 2025
dd49160
Update action.yaml
padms Feb 21, 2025
ade7551
Update action.yaml
padms Feb 21, 2025
46a5c47
Update action.yaml
padms Feb 21, 2025
358b308
Update action.yaml
padms Feb 21, 2025
0853a40
Update action.yaml
padms Feb 21, 2025
c32b885
Update action.yaml
padms Feb 21, 2025
2d9b3a0
Update action.yaml
padms Feb 21, 2025
d65450f
Update action.yaml
padms Feb 21, 2025
634fb60
Update action.yaml
padms Feb 21, 2025
92c8e59
Update action.yaml
padms Feb 21, 2025
87e99d1
Update action.yaml
padms Feb 21, 2025
9200226
Update action.yaml
padms Feb 21, 2025
d466082
Raw output
padms Feb 21, 2025
fd1eea3
Create discussion
padms Feb 24, 2025
1e5ebf2
Update action.yaml
padms Feb 24, 2025
744ce8a
Update action.yaml
padms Feb 24, 2025
feb11c0
Update action.yaml
padms Feb 24, 2025
140aadd
Update action.yaml
padms Feb 24, 2025
410f71f
Update action.yaml
padms Feb 24, 2025
3eb6664
Update action.yaml
padms Feb 24, 2025
6a278d8
Update action.yaml
padms Feb 24, 2025
feb8008
Update action.yaml
padms Feb 24, 2025
91ffe4e
Update action.yaml
padms Feb 24, 2025
c24201a
Update action.yaml
padms Feb 24, 2025
5b1c505
Update action.yaml
padms Feb 24, 2025
32e1a84
Update action.yaml
padms Feb 24, 2025
78bba24
Update action.yaml
padms Feb 24, 2025
c794629
Update action.yaml
padms Feb 24, 2025
ea47bfe
Update action.yaml
padms Feb 24, 2025
82f3dc5
Update action.yaml
padms Feb 24, 2025
b4deaf8
Update action.yaml
padms Feb 24, 2025
b088ccf
Update action.yaml
padms Feb 24, 2025
f2e2cf7
Update action.yaml
padms Feb 24, 2025
e8055c0
Update action.yaml
padms Feb 24, 2025
8b6cb1f
Update action.yaml
padms Feb 24, 2025
86d4c26
Update action.yaml
padms Feb 24, 2025
eacfd37
Update action.yaml
padms Feb 24, 2025
9297bf8
Update action.yaml
padms Feb 24, 2025
f2410aa
Update action.yaml
padms Feb 24, 2025
366a879
Update action.yaml
padms Feb 24, 2025
4df07bf
Update action.yaml
padms Feb 24, 2025
11e6cb0
Update action.yaml
padms Feb 24, 2025
98ce41b
Update action.yaml
padms Feb 24, 2025
53fa1fd
Update action.yaml
padms Feb 24, 2025
2b4e33b
Update action.yaml
padms Feb 28, 2025
a87deb0
Typo
padms Feb 28, 2025
cefccaf
Update action.yaml
padms Feb 28, 2025
b7b82db
Revert "Update action.yaml"
padms Feb 28, 2025
f797fcc
Update action.yaml
padms Feb 28, 2025
fed18ad
Update action.yaml
padms Feb 28, 2025
a518a4c
Update action.yaml
padms Feb 28, 2025
785a688
Update action.yaml
padms Feb 28, 2025
d9e07c1
Update action.yaml
padms Feb 28, 2025
893a7f0
Update action.yaml
padms Feb 28, 2025
33286e9
Update action.yaml
padms Feb 28, 2025
a3ebd8e
Revert "Update action.yaml"
padms Feb 28, 2025
cd7eace
Update action.yaml
padms Feb 28, 2025
bf96a5a
Update action.yaml
padms Feb 28, 2025
43e3968
Update action.yaml
padms Feb 28, 2025
28cf684
Update action.yaml
padms Feb 28, 2025
dba8d84
Revert "Update action.yaml"
padms Feb 28, 2025
bc5878f
Update action.yaml
padms Feb 28, 2025
fd9dd67
Update action.yaml
padms Feb 28, 2025
4e12631
Update action.yaml
padms Feb 28, 2025
68e8bab
Update action.yaml
padms Feb 28, 2025
c99cd23
debug
padms Mar 3, 2025
5f5206f
Update action.yaml
padms Mar 3, 2025
7bb4c38
Update action.yaml
padms Mar 3, 2025
4f0ef2a
Update action.yaml
padms Mar 3, 2025
d33642d
Update action.yaml
padms Mar 3, 2025
05f005a
Update action.yaml
padms Mar 3, 2025
5a2396d
Update action.yaml
padms Mar 3, 2025
19b5298
Lets see
padms Mar 3, 2025
53d201a
lower the limit
padms Mar 3, 2025
195a0b4
Update action.yaml
padms Mar 3, 2025
b0990df
Update action.yaml
padms Mar 3, 2025
df7aa02
Update action.yaml
padms Mar 3, 2025
435465f
Update action.yaml
padms Mar 3, 2025
ba7df04
Update action.yaml
padms Mar 3, 2025
c3cdd5c
Update action.yaml
padms Mar 3, 2025
982fdfd
Update action.yaml
padms Mar 6, 2025
2746cdd
Update action.yaml
padms Mar 6, 2025
780f72f
Update action.yaml
padms Mar 6, 2025
917a9c6
Update action.yaml
padms Mar 6, 2025
d814159
Update action.yaml
padms Mar 6, 2025
4384076
Update action.yaml
padms Mar 6, 2025
b102cda
Update action.yaml
padms Mar 6, 2025
1809ed1
Update action.yaml
padms Mar 6, 2025
2a453d7
Update action.yaml
padms Mar 6, 2025
7c89ccc
Update action.yaml
padms Mar 6, 2025
1c41189
Update action.yaml
padms Mar 6, 2025
6351e46
Update action.yaml
padms Mar 6, 2025
9bb1123
Update action.yaml
padms Mar 6, 2025
c853308
Update action.yaml
padms Mar 6, 2025
a7eb8db
Update action.yaml
padms Mar 6, 2025
c177330
Update action.yaml
padms Mar 6, 2025
758a5cb
Update action.yaml
padms Mar 6, 2025
6721410
Update action.yaml
padms Mar 6, 2025
d87c653
try with SHA
padms Mar 6, 2025
b323519
Update action.yaml
padms Mar 6, 2025
99cb53a
Update action.yaml
padms Mar 6, 2025
bb7d8bd
Merge branch 'main' into padms/2755
padms Mar 6, 2025
34aa03b
Correct webhook
padms Mar 6, 2025
dbd89c8
Nice block formatting
padms Mar 6, 2025
ccc0230
Update action.yaml
padms Mar 6, 2025
1129ec5
Update action.yaml
padms Mar 6, 2025
53f4a91
Update action.yaml
padms Mar 6, 2025
5513409
Update PROD-webs.yaml
padms Mar 6, 2025
3b94952
Formatting
padms Mar 6, 2025
931c4dc
Delete test-workflow.yaml
padms Mar 6, 2025
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
8 changes: 8 additions & 0 deletions .github/workflows/PROD-all-webs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,11 @@ jobs:
git add latest-prod-tags.json
git commit -m "Update latest-prod-tags.json with new tags" || echo "No changes to commit"
git push

- name: 'Move cards and create discussion and post it to channel'
id: 'get-list'
with:
token: ${{ secrets.PADMS_PAT_READ_PACKAGE }}
commitSHA: ${{ github.sha }}
slackWebhook: ${{ secrets.SLACK_WEBHOOK_RELEASE_ANNOUNCEMENT}}
uses: ./.github/workflows/project/
226 changes: 165 additions & 61 deletions .github/workflows/project/action.yaml
Original file line number Diff line number Diff line change
@@ -1,84 +1,188 @@
# This workflow runs whenever a pull request in the repository is marked as "ready for review".
name: Move issue/PR to ✅ Done status
description: 'Move issue'
inputs:
token:
description: 'A Github PAT'
required: true
commitSHA:
description: 'Commit SHA of the Release'
required: true
slackWebhook:
description: 'Slack webhook url of the channel'
required: true

runs:
using: 'composite'
steps:
# Sets environment variables for this step.
#
# If you are using a personal access token, replace `YOUR_TOKEN` with the name of the secret that contains your personal access token.
#
# Replace `YOUR_ORGANIZATION` with the name of your organization. For example, `octo-org`.
#
# Replace `YOUR_PROJECT_NUMBER` with your project number. To find the project number, look at the project URL. For example, `https://github.com/orgs/octo-org/projects/5` has a project number of 5.
- name: Get project data
id: get-project-data
shell: 'bash'
env:
GH_TOKEN: ${{ secrets.PADMS_PAT }}
GH_TOKEN: ${{ inputs.token }}
ORGANIZATION: 'equinor'
PROJECT_NUMBER: 965
# Uses [GitHub CLI](https://cli.github.com/manual/) to query the API for the ID of the project and return the name and ID of the first 20 fields in the project. `fields` returns a union and the query uses inline fragments (`... on`) to return information about any `ProjectV2Field` and `ProjectV2SingleSelectField` fields. The response is stored in a file called `project_data.json`.
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
fields(first:20) {
nodes {
... on ProjectV2Field {
id
name
query($org: String!, $number: Int!, $repository:String!) {
organization(login: $org){
repository(name: $repository){
id
discussionCategory(slug: "Announcements"){
id
}
issues(states:[CLOSED], first:50, orderBy:{
field:UPDATED_AT, direction:DESC}){
nodes{
id
projectItems(first:10, includeArchived:false){
nodes{
id
content{
... on Issue{
number
title
}
}
fieldValueByName( name: "Status") {
... on ProjectV2ItemFieldSingleSelectValue {
status: name
}
}
}
}
}
... on ProjectV2SingleSelectField {
id
name
options {
}
}
projectV2(number: $number) {
id
fields(first:20) {
nodes {
... on ProjectV2Field {
id
name
}
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json

# Parses the response from the API query and stores the relevant IDs as environment variables. Modify this to get the ID for different fields or options. For example:
#
# - To get the ID of a field called `Team`, add `echo 'TEAM_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Team") | .id' project_data.json) >> $GITHUB_ENV`.
# - To get the ID of an option called `Octoteam` for the `Team` single select field, add `echo 'OCTOTEAM_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Team") |.options[] | select(.name=="Octoteam") |.id' project_data.json) >> $GITHUB_ENV`.
#
# **Note:** This workflow assumes that you have a project with a single select field called "Status" that includes an option called "✅ Done" and a date field called "Date posted". You must modify this section to match the fields that are present in your table.

echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
echo 'RELEASE_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="🚀 Release") |.id' project_data.json) >> $GITHUB_ENV
echo 'DONE_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="✅ Done") |.id' project_data.json) >> $GITHUB_ENV

# Sets environment variables for this step. Replace `YOUR_TOKEN` with the name of the secret that contains your personal access token.
# - name: Set fields
# env:
# GH_TOKEN: ${{ secrets.PADMS_PAT }}
# # Sets the value of the `Status` field to `🚀 Release`.
# run: |
# gh api graphql -f query='
# mutation (
# $project: ID!
# $item: ID!
# $status_field: ID!
# $status_value: String!
# ) {
# set_status: updateProjectV2ItemFieldValue(input: {
# projectId: $project
# itemId: $item
# fieldId: $status_field
# value: {
# singleSelectOptionId: $status_value
# }
# }) {
# projectV2Item {
# id
# }
# }
# }' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.RELEASE_OPTION_ID }} --silent
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER -f repository=${{ github.event.repository.name }} > project_data.json

echo "ORGANIZATION=${ORGANIZATION}" >> $GITHUB_ENV
echo "PROJECT_NUMBER=${PROJECT_NUMBER}" >> $GITHUB_ENV

PROJECT_ID=$(jq '.data.organization.projectV2.id' project_data.json)
echo "PROJECT_ID=${PROJECT_ID}" >> $GITHUB_ENV

STATUS_FIELD_ID=$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name=="Status") | .id' project_data.json)
echo "STATUS_FIELD_ID=${STATUS_FIELD_ID}" >> $GITHUB_ENV


DONE_OPTION_ID=$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name=="Status") | .options[] | select(.name=="✅ Done") |.id' project_data.json)
echo "DONE_OPTION_ID=${DONE_OPTION_ID}" >> $GITHUB_ENV


DISCUSSION_CATEGORY_ID=$(jq -r '.data.organization.repository.discussionCategory.id' project_data.json)
echo "DISCUSSION_CATEGORY_ID=${DISCUSSION_CATEGORY_ID}" >> $GITHUB_ENV

REPOSITORY_ID=$(jq -r '.data.organization.repository.id' project_data.json)
echo "REPOSITORY_ID=${REPOSITORY_ID}" >> $GITHUB_ENV

# #Sets environment variables for this step. Replace `YOUR_TOKEN` with the name of the secret that contains your personal access token.
- name: Set fields
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}

# Sets the value of the `Status` field to `✅ Done`.
run: |
ITEMS_IDS=$(jq '.data.organization.repository.issues.nodes[].projectItems.nodes[] | select(.fieldValueByName.status =="🚀 Release") | .id' project_data.json)
echo $ITEMS_IDS
for id in $ITEMS_IDS; do
echo "Moving $id $DONE_OPTION_ID"
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
) {
set_status: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {
singleSelectOptionId: $status_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$id -f status_field=$STATUS_FIELD_ID -f status_value=$DONE_OPTION_ID --silent
done
- name: Create discussion
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
TITLE="Release "
DATE=$(date +'%d-%m-%Y')
TITLE+=$DATE
ITEMS=$(jq -r '.data.organization.repository.issues.nodes[].projectItems.nodes[] | select(.fieldValueByName.status =="🚀 Release") | "- \(.content.title) #\(.content.number)"' project_data.json)
echo "$TITLE"
echo "$ITEMS"
BODY="# Release Log
## Issues closed
"
BODY+="$ITEMS"
BODY+="
## Commit SHA
"
BODY+=${{ inputs.commitSHA }}

echo "$BODY"

gh api graphql -f query='
mutation($title: String!, $repositoryId: ID!, $categoryId: ID!, $body: String!){
createDiscussion(input: {
repositoryId:$repositoryId
categoryId:$categoryId
body:$body
title:$title
}) {

# response type: CreateDiscussionPayload
discussion {
number
}
}}' -f title="$TITLE" -f repositoryId="$REPOSITORY_ID" -f categoryId="$DISCUSSION_CATEGORY_ID" -f body="$BODY" > discussion.json

DISCUSSION_NUMBER=$(jq -r '.data.createDiscussion.discussion.number' discussion.json)
echo "DISCUSSION_NUMBER=${DISCUSSION_NUMBER}" >> $GITHUB_ENV

- name: Post a message in a channel
uses: slackapi/[email protected]
with:
webhook: ${{ inputs.slackWebhook }}
webhook-type: incoming-webhook
payload: |
blocks:
- type: "header"
text:
type: "plain_text"
text: "New release today :rocket:"
- type: "section"
text:
type: "mrkdwn"
text: "Link to release log - https://github.com/${{ github.repository }}/discussions/${{ env.DISCUSSION_NUMBER }}"
11 changes: 0 additions & 11 deletions .github/workflows/test-workflow.yaml

This file was deleted.

Loading