Skip to content

Commit

Permalink
create deployment status github-script-poc.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
daveboster authored Nov 24, 2023
1 parent 8154d6b commit f4ae828
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/github-script-poc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: github-script-poc
on:
push:


env:
project_name: GitHub.Script
environment_name: production
environment_url: https://postman-load-test.azurewebsites.net
deployment_description: Sample GitHub-Script Deployment

jobs:
poc-test:
runs-on: ubuntu-latest
Expand All @@ -12,23 +18,43 @@ jobs:
# with:
# script: console.log(context)

- name: Register Sample Deployment
- 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: "Sample GitHub-Script Deployment",
description: "${{ env.deployment_description }}",
required_contexts: [],
environment: "GitHub.Scripts (live)",
environment: "${{ env.project_name }}-${{ env.environment_name }}",
production_environment: true
});
console.log(deployment);
if (deployment.status === 201) {
core.setOutput('id', deployment.data.id);
return deployment.data;
} else {
throw ne
throw new Error(`Failed to create deployment: ${deployment.status}`);
}
- name: Create Sample Deployment Status
uses: actions/github-script@v4
id: create_github_deployment_status
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',
description: "${{ env.deployment_description }}",
environment_url: "${{ env.environment_url }}",
environment: "${{ env.project_name }}-${{ env.environment_name }}",
});

0 comments on commit f4ae828

Please sign in to comment.