Skip to content

Commit

Permalink
[DEVOPS-337] Switch to labels for ephemeral deployment triggers (#95)
Browse files Browse the repository at this point in the history
<details open>
<summary><a href="https://amuniversal.atlassian.net/browse/DEVOPS-337"
title="DEVOPS-337" target="_blank">DEVOPS-337</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td>TPS UI ephemeral deployments breaking on PR descriptions with code
formatting</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"
src="https://amuniversal.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10308?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>To Do</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
      <td>-</td>
    </tr>
  </table>
</details>
<!--
do not remove this marker as it will break action-jira-linter's
functionality.
  added_by_jira_lint
-->
---

<!-- Please make sure you read the contribution guidelines and then fill
out the blanks below.

Please format the PR title appropriately based on the type of change:
  [JIRA-XXX]: <description>
-->

## Description

- Switch to labels for ephemeral deployment triggers

## Related Links

<!-- List any links related to this pull request here

Replace "JIRA-XXX" with the your Jira issue key -->

- Jira Issue: DEVOPS-337
  • Loading branch information
ebronson68 committed Dec 8, 2023
1 parent 3aa4320 commit c767ff6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/ephemeral-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,24 @@ env:
jobs:
prepare:
name: Preparation Step
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'ephemeral-deployment' || github.event_name == 'pull_request' && github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'ephemeral-deployment') }}
if: ${{ github.event.action == 'labeled' && startsWith(github.event.label.name, 'preview:') || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'preview:') }}
runs-on: ubuntu-latest
steps:
- name: Retrieve Jira ticket ID
- name: Get Jira ticket ID
id: jira-ticket
run: |
PR_BRANCH=$(echo "${{ env.githubPrBranch }}" | grep -Eo "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
PR_TITLE=$(echo "${{ env.githubPrTitle }}" | grep -Eo "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
PR_DESC=$(echo "${{ env.githubPrDescription }}" | grep -Eo "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
echo "PR branch: ${PR_BRANCH}"
echo "PR title: ${PR_TITLE}"
for var in ${PR_BRANCH} ${PR_TITLE} ${PR_DESC}; do JIRA_TICKET_ID=$(echo $var | grep -E ".") && break ; done
if [ -z "${JIRA_TICKET_ID}" ]; then
echo "::error::A Jira issue key is missing from your branch name, pull request title, and pull request description. Please confirm it is linked properly in the pull request."
exit 1
fi
echo "Jira ticket: ${JIRA_TICKET_ID}"
JIRA_TICKET_ID_LC=$(echo "${JIRA_TICKET_ID}" | tr '[:upper:]' '[:lower:]')
echo "jiraTicketIdLc=${JIRA_TICKET_ID_LC}" >> $GITHUB_OUTPUT
Expand All @@ -91,13 +94,14 @@ jobs:
id: environment
shell: bash
run: |
DESCRIPTION="$(echo '${{ env.githubPrDescription }}' | tr -d '`$)(')"
ENVIRONMENT=$(echo "${DESCRIPTION}" | grep -Eo "\- \[x\] .+ Key Vaults" | awk -F ' ' '{print $3}' | tr '[:upper:]' '[:lower:]')
if [ -n "${ENVIRONMENT}" ]; then
LABEL=$(echo "${{ join(github.event.pull_request.labels.*.name, ' ') }}" | grep -o 'preview:[^ ]*' | head -n 1)
if [ -n "${LABEL}" ]; then
ENVIRONMENT=${LABEL#preview:}
echo "Environment extracted from label: ${ENVIRONMENT}"
echo "environment=${ENVIRONMENT}" >> $GITHUB_OUTPUT
else
echo "::notice::Unknown environment key vault. Defaulting to development key vault."
echo "environment=development" >> $GITHUB_OUTPUT
echo "::error::No 'preview:[ENVIRONMENT]' label found."
exit 1
fi
outputs:
environment: ${{ steps.environment.outputs.environment }}
Expand All @@ -107,7 +111,6 @@ jobs:

deploy:
name: Deploy Azure Container Instance
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'ephemeral-deployment' || github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'ephemeral-deployment') }}
needs: [prepare]
runs-on: ubuntu-latest
environment:
Expand Down

0 comments on commit c767ff6

Please sign in to comment.