Skip to content

chore(ci): add appropriate labels to each PR #191

chore(ci): add appropriate labels to each PR

chore(ci): add appropriate labels to each PR #191

Workflow file for this run

name: Pull Request Workflow
on:
pull_request:
branches:
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
pr-labels:
name: PR Labels
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Authenticate GitHub CLI
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
- name: Get Project ID & Field IDs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PROJECT_NUMBER=16 # Change this if needed
# Get the project ID
PROJECT_ID=$(gh api graphql -f query='
query {
organization(login: "kestra-io") {
projectV2(number: 16) {
id
}
}
}' | jq -r '.data.organization.projectV2.id')
echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV
# Get the field IDs for "Contribution" and "Area"
FIELDS=$(gh api graphql -f query='
query {
node(id: "'"$PROJECT_ID"'") {
... on ProjectV2 {
fields(first: 20) {
nodes {
... on ProjectV2SingleSelectField {
id
name
}
... on ProjectV2Field {
id
name
}
}
}
}
}
}')
FIELD_CONTRIBUTION=$(echo $FIELDS | jq -r '.data.node.fields.nodes[] | select(.name == "Contribution") | .id')
FIELD_AREA=$(echo $FIELDS | jq -r '.data.node.fields.nodes[] | select(.name == "Area") | .id')
echo "FIELD_CONTRIBUTION=$FIELD_CONTRIBUTION" >> $GITHUB_ENV
echo "FIELD_AREA=$FIELD_AREA" >> $GITHUB_ENV
- name: Add PR to Project & Set Labels
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_AUTHOR=$(gh pr view ${{ github.event.pull_request.html_url }} --json author --jq '.author.login')
# Add PR to the project
ITEM_ID=$(gh api graphql -f query='
mutation($projectId: ID!, $contentId: ID!) {
addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) {
item {
id
}
}
}' -F projectId="$PROJECT_ID" -F contentId="${{ github.event.pull_request.node_id }}" | jq -r '.data.addProjectV2ItemById.item.id')
echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV
# Determine if the author is an internal contributor
if gh api orgs/kestra-io/members/$PR_AUTHOR --silent; then
gh api graphql -f query='
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
updateProjectV2ItemFieldValue(input: {
projectId: $projectId,
itemId: $itemId,
fieldId: $fieldId,
value: {text: $value}
}) {
projectV2Item {
id
}
}
}' -F projectId="$PROJECT_ID" -F itemId="$ITEM_ID" -F fieldId="$FIELD_CONTRIBUTION" -F value="Internal"
else
gh api graphql -f query='
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
updateProjectV2ItemFieldValue(input: {
projectId: $projectId,
itemId: $itemId,
fieldId: $fieldId,
value: {text: $value}
}) {
projectV2Item {
id
}
}
}' -F projectId="$PROJECT_ID" -F itemId="$ITEM_ID" -F fieldId="$FIELD_CONTRIBUTION" -F value="External"
gh api graphql -f query='
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
updateProjectV2ItemFieldValue(input: {
projectId: $projectId,
itemId: $itemId,
fieldId: $fieldId,
value: {text: $value}
}) {
projectV2Item {
id
}
}
}' -F projectId="$PROJECT_ID" -F itemId="$ITEM_ID" -F fieldId="$FIELD_AREA" -F value="TBD"
fi
file-changes:
name: File changes detection
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
ui: ${{ steps.changes.outputs.ui }}
translations: ${{ steps.changes.outputs.translations }}
backend: ${{ steps.changes.outputs.backend }}
steps:
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
ui:
- 'ui/**'
translations:
- 'ui/src/translations/**'
backend:
- '!{ui,.github}/**'
token: ${{ secrets.GITHUB_TOKEN }}
translations:
name: 'Translations - Generate translations'
runs-on: ubuntu-latest
timeout-minutes: 60
needs: file-changes
steps:
- uses: actions/checkout@v4
name: Checkout - Current ref
if: "needs.file-changes.outputs.translations == 'true'"
- id: generate-translations
name: Translations - Generate translations
if: "needs.file-changes.outputs.translations == 'true'"
uses: ./.github/actions/generate-translations
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
frontend:
name: Frontend - Tests
needs: [file-changes, translations]
if: "needs.file-changes.outputs.ui == 'true'"
uses: ./.github/workflows/workflow-frontend-test.yml
secrets:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
backend:
name: Backend - Tests
needs: file-changes
if: "needs.file-changes.outputs.backend == 'true'"
uses: ./.github/workflows/workflow-backend-test.yml
secrets:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
end:
name: End
runs-on: ubuntu-latest
if: always()
needs: [frontend, backend]
steps:
# Slack
- name: Slack notification
uses: Gamesight/slack-workflow-status@master
if: ${{ always() && env.SLACK_WEBHOOK_URL != 0 }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
name: GitHub Actions
icon_emoji: ":github-actions:"
channel: "C02DQ1A7JLR"