Skip to content

Try to use git commit message github-script-poc.yml #19

Try to use git commit message github-script-poc.yml

Try to use git commit message github-script-poc.yml #19

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: ${{ github.event.commits[0].message }}
jobs:
poc-test:
runs-on: ubuntu-latest
name: Sandbox Testing
environment:
name: GitHub.Script:Production
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@v7
id: github-deployment-create
with:
script: |
const deployment = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.ref,
task: "deploy",
auto_merge: false,
description: "${{ env.deployment_description }}",
required_contexts: [],
environment: "${{ env.project_name }}:${{ env.environment_name }}",
transient_environment: false,
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@v7
id: github-deployment-completed
with:
script: |
const deploymentStatus = await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
auto_inactive: true,
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