Skip to content

Commit e2627e1

Browse files
authored
Add image credentials workflow syntax (#15733)
Add image credentials workflow syntax
1 parent 91a7492 commit e2627e1

2 files changed

Lines changed: 50 additions & 7 deletions

File tree

content/actions/reference/workflow-syntax-for-github-actions.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,25 @@ jobs:
948948

949949
#### **`jobs.<job_id>.container.image`**
950950

951-
The Docker image to use as the container to run the action. The value can be the Docker Hub image name or a public docker registry name.
951+
The Docker image to use as the container to run the action. The value can be the Docker Hub image name or a {% if currentVersion != "free-pro-team@latest" and currentVersion ver_lt "enterprise-server@2.23" %}public{% endif %} registry name.
952+
953+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
954+
#### **`jobs.<job_id>.container.credentials`**
955+
956+
{% data reusables.actions.registry-credentials %}
957+
958+
##### Example
959+
960+
{% raw %}
961+
```yaml
962+
container:
963+
image: ghcr.io/owner/image
964+
credentials:
965+
username: ${{ github.actor }}
966+
password: ${{ secrets.ghcr_token }}
967+
```
968+
{% endraw %}
969+
{% endif %}
952970

953971
#### **`jobs.<job_id>.container.env`**
954972

@@ -1011,19 +1029,43 @@ services:
10111029
- 6379/tcp
10121030
```
10131031

1014-
#### **`jobs.<job_id>.services.image`**
1032+
#### **`jobs.<job_id>.services.<service_id>.image`**
1033+
1034+
The Docker image to use as the service container to run the action. The value can be the Docker Hub image name or a {% if currentVersion != "free-pro-team@latest" and currentVersion ver_lt "enterprise-server@2.23" %}public{% endif %} registry name.
10151035

1016-
The Docker image to use as the service container to run the action. The value can be the Docker base image name or a public docker Hub or registry.
1036+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
1037+
#### **`jobs.<job_id>.services.<service_id>.credentials`**
1038+
1039+
{% data reusables.actions.registry-credentials %}
1040+
1041+
##### Example
1042+
1043+
{% raw %}
1044+
```yaml
1045+
services:
1046+
myservice1:
1047+
image: ghcr.io/owner/myservice1
1048+
credentials:
1049+
username: ${{ github.actor }}
1050+
password: ${{ secrets.ghcr_token }}
1051+
myservice2:
1052+
image: dockerhub_org/myservice2
1053+
credentials:
1054+
username: ${{ secrets.DOCKER_USER }}
1055+
password: ${{ secrets.DOCKER_PASSWORD }}
1056+
```
1057+
{% endraw %}
1058+
{% endif %}
10171059

1018-
#### **`jobs.<job_id>.services.env`**
1060+
#### **`jobs.<job_id>.services.<service_id>.env`**
10191061

10201062
Sets a `map` of environment variables in the service container.
10211063

1022-
#### **`jobs.<job_id>.services.ports`**
1064+
#### **`jobs.<job_id>.services.<service_id>.ports`**
10231065

10241066
Sets an `array` of ports to expose on the service container.
10251067

1026-
#### **`jobs.<job_id>.services.volumes`**
1068+
#### **`jobs.<job_id>.services.<service_id>.volumes`**
10271069

10281070
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.
10291071

@@ -1042,7 +1084,7 @@ volumes:
10421084
- /source/directory:/destination/directory
10431085
```
10441086

1045-
#### **`jobs.<job_id>.services.options`**
1087+
#### **`jobs.<job_id>.services.<service_id>.options`**
10461088

10471089
Additional Docker container resource options. For a list of options, see "[`docker create` options](https://docs.docker.com/engine/reference/commandline/create/#options)."
10481090

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
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`](https://docs.docker.com/engine/reference/commandline/login/) command.

0 commit comments

Comments
 (0)