-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (70 loc) · 2.93 KB
/
github-script-poc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: github-script-poc
on:
push:
env:
project_name: GitHub.Script
environment_name: Production
is_production: false
environment_url: https://postman-load-test.azurewebsites.net
deployment_description: Sample GitHub-Script Deployment
jobs:
poc-test:
runs-on: ubuntu-latest
name: Sandbox Testing
environment:
name: ${{ env.project_name }}-${{ env.environment_name }}
url: ${{ steps.deploy-website.outputs.deployment_url }}
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: github-deployment-create
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: Deployment
id: deploy-website
run: echo "deployment_url=${{ env.environment_url }}" >> "$GITHUB_OUTPUT"
- name: Create Sample Deployment Status (completed)
uses: actions/github-script@v4
id: github-deployment-completed
with:
script: |
const deploymentStatus = await github.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: "${{ steps.github-deployment-create.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 }}
});
- name: Generate Deployment Summary
run: |
echo "This is the lead in sentence for the list" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY # this is a blank line
echo "- Lets add a bullet point" >> $GITHUB_STEP_SUMMARY
echo "- Lets add a second bullet point" >> $GITHUB_STEP_SUMMARY
echo "- How about a third one?" >> $GITHUB_STEP_SUMMARY