Skip to content

Commit

Permalink
chore: tbs
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaklygin committed Jul 13, 2023
1 parent 7b27081 commit 6e1a7df
Showing 1 changed file with 53 additions and 50 deletions.
103 changes: 53 additions & 50 deletions .github/workflows/test-jira-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,69 +156,72 @@ jobs:
# )

# echo "$RESPONSE"
- name: Push Deployment Info to Jira
if: ${{ env.JIRA_KEYS != '' && success() }}
id: push_deployment_info_to_jira
uses: HighwayThree/jira-upload-deployment-info@master
with:
cloud-instance-base-url: '${{ secrets.CLOUD_INSTANCE_BASE_URL }}'
client-id: '${{ secrets.CLIENT_ID }}'
client-secret: '${{ secrets.CLIENT_SECRET }}'
deployment-sequence-number: '${{ github.run_id }}'
update-sequence-number: '${{ github.run_id }}'
issue-keys: "${{ env.JIRA_KEYS }}"
display-name: "Deploy to ${{ env.ENV_NAME }}"
# url: "${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}"
# description: "Prod Deployment"
# last-updated: '${{ github.event.head_commit.timestamp }}'
# label: 'Prod Deployment Label'
state: 'successful'
# pipeline-id: '${{ github.repository }} ${{ github.workflow }}'
# pipeline-display-name: 'Workflow: ${{ github.workflow }} (#${{ github.run_number }})'
# pipeline-url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
environment-id: 'Temploy'
environment-display-name: 'Temploy'
environment-type: 'temploy'
# - name: Push Deployment Info to Jira
# if: ${{ env.JIRA_KEYS != '' && success() }}
# id: push_deployment_info_to_jira
# uses: HighwayThree/jira-upload-deployment-info@master
# with:
# cloud-instance-base-url: '${{ secrets.CLOUD_INSTANCE_BASE_URL }}'
# client-id: '${{ secrets.CLIENT_ID }}'
# client-secret: '${{ secrets.CLIENT_SECRET }}'
# deployment-sequence-number: '${{ github.run_id }}'
# update-sequence-number: '${{ github.run_id }}'
# issue-keys: "${{ env.JIRA_KEYS }}"
# display-name: "Deploy to ${{ env.ENV_NAME }}"
# # url: "${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}"
# # description: "Prod Deployment"
# # last-updated: '${{ github.event.head_commit.timestamp }}'
# # label: 'Prod Deployment Label'
# state: 'successful'
# # pipeline-id: '${{ github.repository }} ${{ github.workflow }}'
# # pipeline-display-name: 'Workflow: ${{ github.workflow }} (#${{ github.run_number }})'
# # pipeline-url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
# environment-id: 'Temploy'
# environment-display-name: 'Temploy'
# environment-type: 'temploy'

- name: Get Access Token
id: get-access-token
if: ${{ env.JIRA_KEYS != '' && success() }}
run: |
ACCESS_TOKEN=$(\
curl --silent \
--request POST \
--url "https://api.atlassian.com/oauth/token" \
--header "Content-Type: application/json" \
--data '{
"grant_type": "client_credentials",
"client_id": "${CLIENT_ID}",
"client_secret": "${CLIENT_SECRET}",
"audience": "api.atlassian.com"
}'
)
# | \
# jq --raw-output '.access_token'
# - name: Get Access Token
# id: get-access-token
# if: ${{ env.JIRA_KEYS != '' && success() }}
# run: |
# ACCESS_TOKEN=$(\
# curl --silent \
# --request POST \
# --url "https://api.atlassian.com/oauth/token" \
# --header "Content-Type: application/json" \
# --data '{
# "grant_type": "client_credentials",
# "client_id": "${CLIENT_ID}",
# "client_secret": "${CLIENT_SECRET}",
# "audience": "api.atlassian.com"
# }'
# )
# # | \
# # jq --raw-output '.access_token'

echo "$ACCESS_TOKEN"
# echo "$ACCESS_TOKEN"

# Check if ACCESS_TOKEN is empty
if [ -z "$ACCESS_TOKEN" ]; then
echo "Error: ACCESS_TOKEN is empty or null"
exit 1
fi
# # Check if ACCESS_TOKEN is empty
# if [ -z "$ACCESS_TOKEN" ]; then
# echo "Error: ACCESS_TOKEN is empty or null"
# exit 1
# fi

echo "ACCESS_TOKEN=$ACCESS_TOKEN" >> $GITHUB_OUTPUT
# echo "ACCESS_TOKEN=$ACCESS_TOKEN" >> $GITHUB_OUTPUT

- name: Send request to Create new JIRA deployment
if: ${{ env.JIRA_KEYS != '' && success() }}
run: |
JIRA_KEYS_QUOTED=$(echo "$JIRA_KEYS" | sed "s/,/\",\"/g")
JIRA_KEYS_QUOTED="\"$JIRA_KEYS_QUOTED\""
AUTH=$(echo -n ${CLIENT_ID}:${CLIENT_SECRET} | base64)
RESPONSE=$(curl --silent \
--request POST \
--url "https://api.atlassian.com/jira/deployments/0.1/cloud/${{ steps.get-cloud-id.outputs.CLOUD_ID }}/bulk" \
--header "Authorization: Bearer ${{ steps.get-access-token.outputs.ACCESS_TOKEN }}" \
--url "${JIRA_BASE_URL}/jira/deployments/0.1/cloud/${{ steps.get-cloud-id.outputs.CLOUD_ID }}/bulk" \
--header "Authorization: Basic ${AUTH}" \
# --header "Authorization: Basic ${{ steps.get-access-token.outputs.ACCESS_TOKEN }}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{
Expand Down

0 comments on commit 6e1a7df

Please sign in to comment.