Dynamic protocol v6 acceptance test helper #808
Workflow file for this run
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
# Copyright (c) HashiCorp, Inc. | |
# SPDX-License-Identifier: MPL-2.0 | |
on: | |
pull_request_target: | |
types: [opened, closed, reopened, edited] | |
workflow_dispatch: | |
name: Jira Community PR Sync | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
name: Jira sync | |
steps: | |
- name: Login | |
uses: atlassian/gajira-login@ca13f8850ea309cf44a6e4e0c49d9aa48ac3ca4c # v3 | |
env: | |
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} | |
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} | |
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} | |
- name: Set ticket type | |
id: set-ticket-type | |
run: | | |
echo "TYPE=GH Issue" >> $GITHUB_OUTPUT | |
- name: Set ticket labels | |
if: github.event.action == 'opened' | |
id: set-ticket-labels | |
run: | | |
LABELS="[\"${{github.event.repository.name}}\", " | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'bug') }}" == "true" ]]; then LABELS+="\"bug\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'enhancement') }}" == "true" ]]; then LABELS+="\"enhancement\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'documentation') }}" == "true" ]]; then LABELS+="\"documentation\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'needs-investigation') }}" == "true" ]]; then LABELS+="\"needs-investigation\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'question') }}" == "true" ]]; then LABELS+="\"question\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'size/XS') }}" == "true" ]]; then LABELS+="\"size/XS\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'size/S') }}" == "true" ]]; then LABELS+="\"size/S\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'size/M') }}" == "true" ]]; then LABELS+="\"size/M\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'size/L') }}" == "true" ]]; then LABELS+="\"size/L\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'size/XL') }}" == "true" ]]; then LABELS+="\"size/XL\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'size/XXL') }}" == "true" ]]; then LABELS+="\"size/XXL\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'acknowledged') }}" == "true" ]]; then LABELS+="\"acknowledged\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'help wanted') }}" == "true" ]]; then LABELS+="\"help wanted\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'upstream-terraform') }}" == "true" ]]; then LABELS+="\"upstream-terraform\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'upstream-terraform') }}" == "true" ]]; then LABELS+="\"upstream-terraform\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'progressive apply') }}" == "true" ]]; then LABELS+="\"progressive apply\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'pr/changelog') }}" == "true" ]]; then LABELS+="\"pr/changelog\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'crash') }}" == "true" ]]; then LABELS+="\"crash\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'breaking-change') }}" == "true" ]]; then LABELS+="\"breaking-change\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'provider') }}" == "true" ]]; then LABELS+="\"provider\", "; fi | |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'stale') }}" == "true" ]]; then LABELS+="\"stale\", "; fi | |
if [[ ${#LABELS} != 1 ]]; then LABELS=${LABELS::-2}"]"; else LABELS+="]"; fi | |
echo "LABELS=${LABELS}" >> $GITHUB_OUTPUT | |
- name: Create ticket if a PR is opened | |
if: ( github.event.action == 'opened') | |
uses: tomhjp/gh-action-jira-create@3ed1789cad3521292e591a7cfa703215ec1348bf # v0.2.1 | |
with: | |
project: TFECO | |
issuetype: "${{ steps.set-ticket-type.outputs.TYPE }}" | |
summary: "${{ github.event.pull_request.title }}:[PR-${{ github.event.pull_request.number }}] (${{ github.event.repository.name }})" | |
description: "${{ github.event.issue.body || github.event.pull_request.body }}\n\n_Created in GitHub by ${{ github.actor }}._\n\n${{ github.event.pull_request.html_url }}" | |
# customfield_10089 is "Issue Link", customfield_10371 is "Source" (use JIRA API to retrieve) | |
extraFields: '{ "customfield_10089": "${{ github.event.pull_request.html_url }}", | |
"customfield_10371": { "value": "GitHub" }, | |
"customfield_10091": ["TF-HybridCloud"], | |
"labels": ${{ steps.set-ticket-labels.outputs.LABELS }} }' | |
env: | |
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} | |
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} | |
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} | |
- name: Search | |
if: github.event.action != 'opened' | |
id: search | |
uses: tomhjp/gh-action-jira-search@04700b457f317c3e341ce90da5a3ff4ce058f2fa # v0.2.2 | |
with: | |
# cf[10089] is Issue Link (use JIRA API to retrieve) | |
jql: 'issuetype = "${{ steps.set-ticket-type.outputs.TYPE }}" and cf[10089] = "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"' | |
- name: Sync comment | |
if: github.event.action == 'created' && steps.search.outputs.issue | |
uses: tomhjp/gh-action-jira-comment@6eb6b9ead70221916b6badd118c24535ed220bd9 # v0.2.0 | |
with: | |
issue: ${{ steps.search.outputs.issue }} | |
comment: "${{ github.actor }} ${{ github.event.review.state || 'commented' }}:\n\n${{ github.event.comment.body || github.event.review.body }}\n\n${{ github.event.comment.html_url || github.event.review.html_url }}" | |
- name: Close PR | |
if: ( github.event.action == 'closed' || github.event.action == 'deleted' || github.event.pull_request.merged == true) && steps.search.outputs.issue | |
uses: atlassian/gajira-transition@38fc9cd61b03d6a53dd35fcccda172fe04b36de3 # v3 | |
with: | |
issue: ${{ steps.search.outputs.issue }} | |
transition: "Closed" | |
- name: Reopen PR | |
if: github.event.action == 'reopened' && steps.search.outputs.issue | |
uses: atlassian/gajira-transition@38fc9cd61b03d6a53dd35fcccda172fe04b36de3 # v3 | |
with: | |
issue: ${{ steps.search.outputs.issue }} | |
transition: "To Do" |