Skip to content

fix syntax error for job environment github-script-poc.yml #12

fix syntax error for job environment github-script-poc.yml

fix syntax error for job environment github-script-poc.yml #12

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 }}

Check failure on line 17 in .github/workflows/github-script-poc.yml

View workflow run for this annotation

GitHub Actions / github-script-poc

Invalid workflow file

The workflow is not valid. .github/workflows/github-script-poc.yml (Line: 17, Col: 13): Unrecognized named-value: 'env'. Located at position 1 within expression: env.project_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