Skip to content

Commit 0bfe7eb

Browse files
authored
Fix GitHub Actions workflow container schema (SchemaStore#5597)
1 parent c2c73d1 commit 0bfe7eb

4 files changed

Lines changed: 112 additions & 10 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# yaml-language-server: $schema=../../schemas/json/github-workflow.json
2+
name: Invalid container command
3+
on:
4+
- push
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
container:
9+
image: node:18
10+
command: npm test
11+
steps:
12+
- run: npm test
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# yaml-language-server: $schema=../../schemas/json/github-workflow.json
2+
name: Invalid container entrypoint
3+
on:
4+
- push
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
container:
9+
image: node:18
10+
entrypoint: node
11+
steps:
12+
- run: node --version

src/schemas/json/github-workflow.json

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@
6262
}
6363
]
6464
},
65-
"container": {
65+
"jobContainer": {
6666
"type": "object",
6767
"properties": {
6868
"image": {
69-
"$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerimage",
69+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainerimage",
7070
"description": "The Docker image to use as the container to run the action. The value can be the Docker Hub image name or a registry name.",
7171
"type": "string"
7272
},
7373
"credentials": {
74-
"$comment": "https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainercredentials",
74+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainercredentials",
7575
"description": "If the image's container registry requires authentication to pull the image, you can use credentials to set a map of the username and password. The credentials are the same values that you would provide to the `docker login` command.",
7676
"type": "object",
7777
"properties": {
@@ -84,12 +84,12 @@
8484
}
8585
},
8686
"env": {
87-
"$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerenv",
87+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainerenv",
8888
"$ref": "#/definitions/env",
89-
"description": "Sets an array of environment variables in the container."
89+
"description": "Sets a map of environment variables in the container."
9090
},
9191
"ports": {
92-
"$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerports",
92+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainerports",
9393
"description": "Sets an array of ports to expose on the container.",
9494
"type": "array",
9595
"items": {
@@ -105,7 +105,7 @@
105105
"minItems": 1
106106
},
107107
"volumes": {
108-
"$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes",
108+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainervolumes",
109109
"description": "Sets an array of volumes for the container to use. You can use volumes to share data between services or other steps in a job. You can specify named Docker volumes, anonymous Docker volumes, or bind mounts on the host.\nTo specify a volume, you specify the source and destination path: <source>:<destinationPath>\nThe <source> is a volume name or an absolute path on the host machine, and <destinationPath> is an absolute path in the container.",
110110
"type": "array",
111111
"items": {
@@ -114,14 +114,84 @@
114114
"minItems": 1
115115
},
116116
"options": {
117-
"$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontaineroptions",
117+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontaineroptions",
118118
"description": "Additional Docker container resource options. For a list of options, see https://docs.docker.com/engine/reference/commandline/create/#options.",
119119
"type": "string"
120120
}
121121
},
122122
"required": ["image"],
123123
"additionalProperties": false
124124
},
125+
"serviceContainer": {
126+
"type": "object",
127+
"properties": {
128+
"image": {
129+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idimage",
130+
"description": "The Docker image to use as the service container to run the action. The value can be the Docker Hub image name or a registry name.",
131+
"type": "string"
132+
},
133+
"credentials": {
134+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idcredentials",
135+
"description": "If the image's container registry requires authentication to pull the image, you can use credentials to set a map of the username and password. The credentials are the same values that you would provide to the `docker login` command.",
136+
"type": "object",
137+
"properties": {
138+
"username": {
139+
"type": "string"
140+
},
141+
"password": {
142+
"type": "string"
143+
}
144+
}
145+
},
146+
"env": {
147+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idenv",
148+
"$ref": "#/definitions/env",
149+
"description": "Sets a map of environment variables in the service container."
150+
},
151+
"ports": {
152+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idports",
153+
"description": "Sets an array of ports to expose on the service container.",
154+
"type": "array",
155+
"items": {
156+
"oneOf": [
157+
{
158+
"type": "number"
159+
},
160+
{
161+
"type": "string"
162+
}
163+
]
164+
},
165+
"minItems": 1
166+
},
167+
"volumes": {
168+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idvolumes",
169+
"description": "Sets an array of volumes for the service container to use. You can use volumes to share data between services or other steps in a job. You can specify named Docker volumes, anonymous Docker volumes, or bind mounts on the host.\nTo specify a volume, you specify the source and destination path: <source>:<destinationPath>\nThe <source> is a volume name or an absolute path on the host machine, and <destinationPath> is an absolute path in the container.",
170+
"type": "array",
171+
"items": {
172+
"type": "string"
173+
},
174+
"minItems": 1
175+
},
176+
"options": {
177+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idoptions",
178+
"description": "Additional Docker container resource options. For a list of options, see https://docs.docker.com/engine/reference/commandline/create/#options.",
179+
"type": "string"
180+
},
181+
"command": {
182+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idcommand",
183+
"description": "Overrides the Docker image's default command (`CMD`). The value is passed as arguments after the image name in the `docker create` command. If you also specify `entrypoint`, `command` provides the arguments to that entrypoint.",
184+
"type": "string"
185+
},
186+
"entrypoint": {
187+
"$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_identrypoint",
188+
"description": "Overrides the Docker image's default `ENTRYPOINT`. The value is a single string defining the executable to run. Use this when you need to replace the image's entrypoint entirely. You can combine `entrypoint` with `command` to pass arguments to the custom entrypoint.",
189+
"type": "string"
190+
}
191+
},
192+
"required": ["image"],
193+
"additionalProperties": false
194+
},
125195
"defaults": {
126196
"type": "object",
127197
"properties": {
@@ -829,7 +899,7 @@
829899
"type": "string"
830900
},
831901
{
832-
"$ref": "#/definitions/container"
902+
"$ref": "#/definitions/jobContainer"
833903
}
834904
]
835905
},
@@ -838,7 +908,7 @@
838908
"description": "Additional containers to host services for a job in a workflow. These are useful for creating databases or cache services like redis. The runner on the virtual machine will automatically create a network and manage the life cycle of the service containers.\nWhen you use a service container for a job or your step uses container actions, you don't need to set port information to access the service. Docker automatically exposes all ports between containers on the same network.\nWhen both the job and the action run in a container, you can directly reference the container by its hostname. The hostname is automatically mapped to the service name.\nWhen a step does not use a container action, you must access the service using localhost and bind the ports.",
839909
"type": "object",
840910
"additionalProperties": {
841-
"$ref": "#/definitions/container"
911+
"$ref": "#/definitions/serviceContainer"
842912
}
843913
},
844914
"concurrency": {

src/test/github-workflow/containers.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ jobs:
1616
credentials:
1717
username: ${{ github.repository_owner }}
1818
password: ${{ secrets.ghcr_password }}
19+
command: >-
20+
--sql_mode=STRICT_TRANS_TABLES --max_allowed_packet=512M
21+
etcd:
22+
image: quay.io/coreos/etcd:v3.5.17
23+
entrypoint: etcd
24+
command: >-
25+
--listen-client-urls http://0.0.0.0:2379
26+
--advertise-client-urls http://0.0.0.0:2379
1927
test:
2028
runs-on:
2129
- self-hosted

0 commit comments

Comments
 (0)