Add log_url github-script-poc.yml #7
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
name: github-script-poc | |
on: | |
push: | |
env: | |
project_name: GitHub.Script | |
environment_name: production | |
is_production: true | |
environment_url: https://postman-load-test.azurewebsites.net | |
deployment_description: Sample GitHub-Script Deployment | |
jobs: | |
poc-test: | |
runs-on: ubuntu-latest | |
name: Sandbox Testing | |
steps: | |
# - name: View context attributes | |
# uses: actions/github-script@v7 | |
# with: | |
# script: console.log(context) | |
- name: Create Sample GitHub Deployment | |
uses: actions/github-script@v4 | |
id: create_github_deployment | |
with: | |
script: | | |
const deployment = await github.repos.createDeployment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: context.ref, | |
auto_merge: false, | |
description: "${{ env.deployment_description }}", | |
required_contexts: [], | |
task: "deploy", | |
environment: "${{ env.project_name }}-${{ env.environment_name }}", | |
production_environment: "${{ env.is_production }}" | |
}); | |
console.log(deployment); | |
if (deployment.status === 201) { | |
core.setOutput('id', deployment.data.id); | |
return deployment.data; | |
} else { | |
throw new Error(`Failed to create deployment: ${deployment.status}`); | |
} | |
- name: Create Sample Deployment Status (completed) | |
uses: actions/github-script@v4 | |
id: create_github_deployment_status_completed | |
with: | |
script: | | |
let deploymentId = "${{ steps.get_deployment.outputs.id }}"; | |
let environmentUrl = "${{ steps.get_deployment.outputs.url }}"; | |
const deploymentStatus = await github.repos.createDeploymentStatus({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
deployment_id: "${{ steps.create_github_deployment.outputs.id }}", | |
state: 'success', | |
log_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | |
description: "${{ env.deployment_description }}", | |
environment_url: "${{ env.environment_url }}", | |
environment: "${{ env.project_name }}-${{ env.environment_name }}", | |
production_environment: "${{ env.is_production }}" | |
}); |