Skip to content

Commit

Permalink
Switch to trigger-jenkins-job action
Browse files Browse the repository at this point in the history
  • Loading branch information
jcobarreto committed Dec 26, 2023
1 parent 22a586c commit c15eaff
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 149 deletions.
116 changes: 64 additions & 52 deletions create-jira-deployment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ description: |
envInputs:
JENKINS_USER: Jenkins user
JENKINS_BUILD_TOKEN: Jenkins build token. Keep in mind that tokens for `temploy` and `staging` differ
PROXY: Proxy to use for Jenkins
inputs:
token:
# token:
# required: true
# description: 'GitHub token to create a deployment'
jenkins_build_url:
description: 'Jenkins build instance URL'
required: true
jenkins_build_user:
description: 'Jenkins build user'
required: true
jenkins_build_token:
description: 'Jenkins build token'
required: true
jenkins_sa_credentials:
description: 'Jenkins service account credentials to use with IAP'
required: true
description: 'GitHub token to create a deployment'
environment-url:
required: false
description: 'URL of the environment'
Expand All @@ -30,64 +41,65 @@ inputs:
default: 'false'
description: Creates a Github Deployment along with JIRA Deployment


runs:
using: composite
steps:
- uses: chrnorm/deployment-action@v2
name: Create GitHub deployment
id: gh-deployment
if: ${{ always() && inputs.create-gh-deployment == 'true' }}
with:
token: ${{ inputs.token }}
environment-url: ${{ inputs.environment-url }}
environment: ${{ inputs.environment }}
transient-environment: ${{ inputs.transient-environment }}
auto-inactive: ${{ inputs.auto-inactive }}
# - uses: chrnorm/deployment-action@v2
# name: Create GitHub deployment
# id: gh-deployment
# if: ${{ always() && inputs.create-gh-deployment == 'true' }}
# with:
# token: ${{ inputs.token }}
# environment-url: ${{ inputs.environment-url }}
# environment: ${{ inputs.environment }}
# transient-environment: ${{ inputs.transient-environment }}
# auto-inactive: ${{ inputs.auto-inactive }}

- name: Update deployment status on success
if: ${{ success() && inputs.create-gh-deployment == 'true' }}
uses: chrnorm/deployment-status@v2
with:
token: ${{ inputs.token }}
environment-url: ${{ steps.gh-deployment.outputs.environment_url }}
deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }}
log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: 'success'
# - name: Update deployment status on success
# if: ${{ success() && inputs.create-gh-deployment == 'true' }}
# uses: chrnorm/deployment-status@v2
# with:
# token: ${{ inputs.token }}
# environment-url: ${{ steps.gh-deployment.outputs.environment_url }}
# deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }}
# log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# state: 'success'

- name: Update deployment status on failure
if: ${{ failure() && inputs.create-gh-deployment == 'true' }}
uses: chrnorm/deployment-status@v2
with:
token: ${{ inputs.token }}
environment-url: ${{ steps.gh-deployment.outputs.environment_url }}
deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }}
log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: 'failure'
# - name: Update deployment status on failure
# if: ${{ failure() && inputs.create-gh-deployment == 'true' }}
# uses: chrnorm/deployment-status@v2
# with:
# token: ${{ inputs.token }}
# environment-url: ${{ steps.gh-deployment.outputs.environment_url }}
# deployment-id: ${{ steps.gh-deployment.outputs.deployment_id }}
# log-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# state: 'failure'

- name: Set appName
id: repo
if: ${{ always() }}
shell: bash
run: |
echo APP_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) >> $GITHUB_OUTPUT
# - name: Set appName
# id: repo
# if: ${{ always() }}
# shell: bash
# run: |
# echo APP_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) >> $GITHUB_OUTPUT

- id: sha
uses: toptal/davinci-github-actions/get-workflow-sha@master
# - id: sha
# uses: toptal/davinci-github-actions/get-workflow-sha@master

- name: Trigger `Create JIRA` deployment
uses: toptal/jenkins-job[email protected]
uses: toptal/actions/trigger-jenkins-job@main
if: ${{ always() }}
with:
jenkins_url: https://jenkins-build.toptal.net/
jenkins_user: ${{ env.JENKINS_USER }}
jenkins_token: ${{ env.JENKINS_BUILD_TOKEN }}
proxy: ${{ env.PROXY }}
job_name: create-jira-deployment
job_params: |
{
"appName": "${{ steps.repo.outputs.APP_NAME }}",
"envName": "${{ inputs.environment }}",
"sha": "${{ github.event.pull_request.head.sha || steps.sha.outputs.result }}"
}
jenkins_url: ${{ inputs.jenkins_build_url }}
jenkins_user: ${{ inputs.jenkins_build_user }}
jenkins_token: ${{ inputs.jenkins_build_token }}
jenkins_client_id: ${{ inputs.jenkins_client_id }}
jenkins_sa_credentials: ${{ inputs.jenkins_sa_credentials }}
# job_name: create-jira-deployment
# job_params: |
# {
# "appName": "${{ steps.repo.outputs.APP_NAME }}",
# "envName": "${{ inputs.environment }}",
# "sha": "${{ github.event.pull_request.head.sha || steps.sha.outputs.result }}"
# }
job_name: job-test-iap
job_timeout: '3600'
Loading

0 comments on commit c15eaff

Please sign in to comment.