Add deployment key support for job environment (#338)
Add a boolean 'deployment' property to the job environment mapping. When set to false, the parsed environment reference sets skipDeployment to signal that no deployment record should be created.
This commit is contained in:
@@ -368,6 +368,24 @@ jobs:
|
||||
});
|
||||
});
|
||||
|
||||
describe("environment deployment", () => {
|
||||
it("allows deployment boolean under environment mapping", async () => {
|
||||
const workflow = `
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: prod
|
||||
deployment: false
|
||||
steps:
|
||||
- run: echo
|
||||
`;
|
||||
const result = await validate(createDocument("wf.yaml", workflow));
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("workflow_dispatch", () => {
|
||||
it("allows empty string in choice options", async () => {
|
||||
const result = await validate(
|
||||
|
||||
@@ -34,6 +34,14 @@ export function convertToActionsEnvironmentRef(
|
||||
case "url":
|
||||
result.url = property.value;
|
||||
break;
|
||||
|
||||
case "deployment": {
|
||||
const deploymentValue = property.value.assertBoolean("job environment deployment");
|
||||
if (deploymentValue.value === false) {
|
||||
result.skipDeployment = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ export type ConcurrencySetting = {
|
||||
export type ActionsEnvironmentReference = {
|
||||
name?: TemplateToken;
|
||||
url?: TemplateToken;
|
||||
skipDeployment?: boolean;
|
||||
};
|
||||
|
||||
export type WorkflowJob = Job | ReusableWorkflowJob;
|
||||
|
||||
@@ -2079,6 +2079,10 @@
|
||||
"url": {
|
||||
"type": "string-runner-context-no-secrets",
|
||||
"description": "The environment URL, which maps to `environment_url` in the deployments API."
|
||||
},
|
||||
"deployment": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to create a deployment record for this environment. Defaults to true."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
include-source: false # Drop file/line/col from output
|
||||
skip:
|
||||
- C#
|
||||
---
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
environment:
|
||||
name: production
|
||||
deployment: false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo hi
|
||||
build2:
|
||||
environment:
|
||||
name: staging
|
||||
deployment: true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo hi
|
||||
---
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"type": "job",
|
||||
"id": "build",
|
||||
"name": "build",
|
||||
"if": {
|
||||
"type": 3,
|
||||
"expr": "success()"
|
||||
},
|
||||
"environment": {
|
||||
"type": 2,
|
||||
"map": [
|
||||
{
|
||||
"Key": "name",
|
||||
"Value": "production"
|
||||
},
|
||||
{
|
||||
"Key": "deployment",
|
||||
"Value": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"id": "__run",
|
||||
"if": {
|
||||
"type": 3,
|
||||
"expr": "success()"
|
||||
},
|
||||
"run": "echo hi"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "job",
|
||||
"id": "build2",
|
||||
"name": "build2",
|
||||
"if": {
|
||||
"type": 3,
|
||||
"expr": "success()"
|
||||
},
|
||||
"environment": {
|
||||
"type": 2,
|
||||
"map": [
|
||||
{
|
||||
"Key": "name",
|
||||
"Value": "staging"
|
||||
},
|
||||
{
|
||||
"Key": "deployment",
|
||||
"Value": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"runs-on": "ubuntu-latest",
|
||||
"steps": [
|
||||
{
|
||||
"id": "__run",
|
||||
"if": {
|
||||
"type": 3,
|
||||
"expr": "success()"
|
||||
},
|
||||
"run": "echo hi"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user