mirror of
https://github.com/nginx/nginx.git
synced 2026-06-30 05:43:02 +00:00
When a new issue is created, set its 'Created at' date in the corresponding project.
This commit is contained in:
parent
a43c76b4e3
commit
319b4ea63f
1 changed files with 104 additions and 0 deletions
104
.github/workflows/set-creation-date.yaml
vendored
Normal file
104
.github/workflows/set-creation-date.yaml
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
name: Set creation date
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
set-date:
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
if: ${{ github.repository == 'nginx/nginx' }}
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Get secrets from Azure
|
||||||
|
uses: nginx/ci-self-hosted/.github/actions/get-from-vault@5c3e1f8b51f66a851fdba80f70e19cf966199730
|
||||||
|
with:
|
||||||
|
client-id: ${{ secrets.NGINX_OSS_CLIENT_ID }}
|
||||||
|
tenant-id: ${{ secrets.NGINX_OSS_TENANT_ID }}
|
||||||
|
vault-name: ${{ secrets.NGINX_OSS_VAULT_NAME }}
|
||||||
|
secret-names: "github-nginx-oss-app-project-client-id, github-nginx-oss-app-project-private-key"
|
||||||
|
env-names: "NGINX_OSS_PROJ_CLIENT_ID, NGINX_OSS_PROJ_PRIV_KEY"
|
||||||
|
|
||||||
|
- name: Generate token
|
||||||
|
id: generate-token
|
||||||
|
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
|
||||||
|
with:
|
||||||
|
client-id: ${{ env.NGINX_OSS_PROJ_CLIENT_ID }}
|
||||||
|
private-key: ${{ env.NGINX_OSS_PROJ_PRIV_KEY }}
|
||||||
|
|
||||||
|
- name: Get project data
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
|
ORGANIZATION: nginx
|
||||||
|
PROJECT_NUMBER: 33
|
||||||
|
run: |
|
||||||
|
gh api graphql -f query='
|
||||||
|
query($org: String!, $number: Int!) {
|
||||||
|
organization(login: $org) {
|
||||||
|
projectV2(number: $number) {
|
||||||
|
id
|
||||||
|
fields(first:20) {
|
||||||
|
nodes {
|
||||||
|
... on ProjectV2FieldCommon {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER >project_data.json
|
||||||
|
|
||||||
|
echo 'PROJECT_ID='$(jq -r '.data.organization.projectV2.id' project_data.json) >>$GITHUB_ENV
|
||||||
|
echo 'DATE_FIELD_ID='$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name == "Created at") | .id' project_data.json) >>$GITHUB_ENV
|
||||||
|
|
||||||
|
# Needed to get the item's Global ID
|
||||||
|
- name: Add item to project
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
|
run: |
|
||||||
|
NODE_ID=${{ github.event.issue.node_id }}
|
||||||
|
|
||||||
|
item_id="$(gh api graphql -f query='
|
||||||
|
mutation($project:ID!, $item:ID!) {
|
||||||
|
addProjectV2ItemById(
|
||||||
|
input: {
|
||||||
|
projectId: $project, contentId: $item
|
||||||
|
}) {
|
||||||
|
item {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f item=$NODE_ID --jq '.data.addProjectV2ItemById.item.id')"
|
||||||
|
echo 'ITEM_ID='$item_id >>$GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set item creation date
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
|
run: |
|
||||||
|
DATE=${{ github.event.issue.created_at }}
|
||||||
|
|
||||||
|
gh api graphql -f query='
|
||||||
|
mutation(
|
||||||
|
$project: ID!
|
||||||
|
$item: ID!
|
||||||
|
$date_field: ID!
|
||||||
|
$date: Date!
|
||||||
|
) {
|
||||||
|
updateProjectV2ItemFieldValue(
|
||||||
|
input: {
|
||||||
|
projectId: $project
|
||||||
|
itemId: $item
|
||||||
|
fieldId: $date_field
|
||||||
|
value: {
|
||||||
|
date: $date
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
projectV2Item {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date=$DATE
|
||||||
Loading…
Add table
Add a link
Reference in a new issue