update default registry creds
This commit is contained in:
+30
-40
@@ -8,9 +8,11 @@ the version that was just built.
|
|||||||
|
|
||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
1. **Get next version** — calls the sibling
|
1. **Checkout** — checks out the triggering repository via
|
||||||
[`get-next-version`](../get-next-version/action.yml:1) action via
|
`actions/checkout@v7`, optionally with Git LFS support.
|
||||||
`self:captbrick/gitea-actions/get-next-version@master`, forwarding
|
2. **Get next version** — calls the sibling
|
||||||
|
[`get-next-version`](../get-next-version/action.yml:1) action via its
|
||||||
|
full URL on the Gitea instance, forwarding
|
||||||
`main_branch`, `major`, `minor`, `image_registry`, `image_repository`,
|
`main_branch`, `major`, `minor`, `image_registry`, `image_repository`,
|
||||||
and `target` as its `image_name` input. When `image_registry` is empty,
|
and `target` as its `image_name` input. When `image_registry` is empty,
|
||||||
`get-next-version` falls back to its own default (`gitea.livingeach.day`)
|
`get-next-version` falls back to its own default (`gitea.livingeach.day`)
|
||||||
@@ -23,20 +25,20 @@ the version that was just built.
|
|||||||
`IMAGE_REGISTRY` and `IMAGE_TAG` into `$GITEA_ENV`, which the remaining
|
`IMAGE_REGISTRY` and `IMAGE_TAG` into `$GITEA_ENV`, which the remaining
|
||||||
steps consume directly, and also re-exposes `version` / `version_tag` /
|
steps consume directly, and also re-exposes `version` / `version_tag` /
|
||||||
`image_tag` as this action's own outputs.
|
`image_tag` as this action's own outputs.
|
||||||
2. **Prepare cache refs** — when `cache` is enabled (default), computes two
|
3. **Prepare cache refs** — when `cache` is enabled (default), computes two
|
||||||
registry-backed BuildKit cache refs below the final lowercased image
|
registry-backed BuildKit cache refs below the final lowercased image
|
||||||
repository's dedicated `cache` repository: one for the base branch and one
|
repository's dedicated `cache` repository: one for the base branch and one
|
||||||
for the current/head branch. Branch names are lowercased and sanitized so
|
for the current/head branch. Branch names are lowercased and sanitized so
|
||||||
refs like `feature/foo` become valid Docker tags such as `feature-foo`. For
|
refs like `feature/foo` become valid Docker tags such as `feature-foo`. For
|
||||||
merge commits, the action also tries to detect the merged source branch from
|
merge commits, the action also tries to detect the merged source branch from
|
||||||
the commit message and adds that branch cache as an extra cache source.
|
the commit message and adds that branch cache as an extra cache source.
|
||||||
3. **Docker login** — runs when either `push` or `cache` is enabled, because
|
4. **Docker login** — runs when either `push` or `cache` is enabled, because
|
||||||
registry cache import/export needs registry authentication too.
|
registry cache import/export needs registry authentication too.
|
||||||
4. **Set up QEMU** — always run via `docker/setup-qemu-action`, so the runner
|
5. **Set up QEMU** — always run via `docker/setup-qemu-action`, so the runner
|
||||||
can emulate non-native architectures and has a Buildx builder with full
|
can emulate non-native architectures and has a Buildx builder with full
|
||||||
feature support (registry cache export, multi-platform output), regardless
|
feature support (registry cache export, multi-platform output), regardless
|
||||||
of how many entries `platforms` has.
|
of how many entries `platforms` has.
|
||||||
5. **Build and push image** — always runs `docker buildx build`, passing
|
6. **Build and push image** — always runs `docker buildx build`, passing
|
||||||
`--build-arg APP_VERSION=$VERSION`, `--tag $IMAGE_TAG`, `-f <dockerfile>`,
|
`--build-arg APP_VERSION=$VERSION`, `--tag $IMAGE_TAG`, `-f <dockerfile>`,
|
||||||
optional `--target <target>`, and `--platform <platforms>` (default
|
optional `--target <target>`, and `--platform <platforms>` (default
|
||||||
`linux/amd64`). When `cache` is enabled, adds `--cache-from` for the base,
|
`linux/amd64`). When `cache` is enabled, adds `--cache-from` for the base,
|
||||||
@@ -48,7 +50,7 @@ the version that was just built.
|
|||||||
(when `cache: 'true'`), but produces no local image; it only warms the
|
(when `cache: 'true'`), but produces no local image; it only warms the
|
||||||
cache. See [Building for multiple platforms](#building-for-multiple-platforms)
|
cache. See [Building for multiple platforms](#building-for-multiple-platforms)
|
||||||
below.
|
below.
|
||||||
6. **Create version tag** — gated behind the `push` input (default on);
|
7. **Create version tag** — gated behind the `push` input (default on);
|
||||||
commits a Git tag named after `$VERSION_TAG` using the
|
commits a Git tag named after `$VERSION_TAG` using the
|
||||||
`gitea-actions[bot]` identity and pushes it. Setting `push: 'false'`
|
`gitea-actions[bot]` identity and pushes it. Setting `push: 'false'`
|
||||||
skips the image push and Git tag creation/push; if `cache` is still enabled,
|
skips the image push and Git tag creation/push; if `cache` is still enabled,
|
||||||
@@ -65,28 +67,22 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: https://gitea.livingeach.day/captbrick/gitea-actions/docker-build-push@main
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- uses: self:captbrick/gitea-actions/docker-build-push@master
|
|
||||||
with:
|
with:
|
||||||
main_branch: master
|
main_branch: master
|
||||||
major: 1
|
|
||||||
minor: 1
|
|
||||||
registry_username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> The workflow needs `permissions: contents: write` so the action can push
|
> **Required secrets:** The consuming repository must have `DOCKER_USER` and
|
||||||
> the Git tag it creates. The checkout step needs `fetch-depth: 0` so the
|
> `DOCKER_PASSWORD` secrets configured (under **Repository → Settings →
|
||||||
> full tag history is available to `get-next-version`. Set `push: 'false'`
|
> Secrets**), or you must pass `registry_username` / `registry_password`
|
||||||
> to build without pushing the final image or creating a Git tag — the build
|
> explicitly.
|
||||||
> runs but produces no accessible image (just warms the cache, if enabled).
|
>
|
||||||
> With the default `cache: 'true'`, the action still logs in and updates the
|
> **Note:** Gitea Actions resolves `uses:` references anonymously. The
|
||||||
> branch BuildKit cache; set `cache: 'false'` as well to skip registry
|
> actions repository must be publicly accessible (or the Gitea instance must
|
||||||
> interaction entirely.
|
> have `DEFAULT_ACTIONS_URL = self` with Cross-Repository Access enabled on
|
||||||
|
> Gitea 1.26+). If your Gitea has `REQUIRE_SIGNIN_VIEW = true`, ensure the
|
||||||
|
> actions repo is set to public so the runner can clone it without
|
||||||
|
> authentication.
|
||||||
|
|
||||||
### Multiple images from one Dockerfile
|
### Multiple images from one Dockerfile
|
||||||
|
|
||||||
@@ -108,29 +104,23 @@ target:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Warm up build cache
|
- name: Warm up build cache
|
||||||
uses: self:captbrick/gitea-actions/docker-build-push@master
|
uses: https://gitea.livingeach.day/captbrick/gitea-actions/docker-build-push@main
|
||||||
with:
|
with:
|
||||||
main_branch: master
|
main_branch: master
|
||||||
target: build-all
|
target: build-all
|
||||||
push: 'false'
|
push: 'false'
|
||||||
registry_username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build & push frontend
|
- name: Build & push frontend
|
||||||
uses: self:captbrick/gitea-actions/docker-build-push@master
|
uses: https://gitea.livingeach.day/captbrick/gitea-actions/docker-build-push@main
|
||||||
with:
|
with:
|
||||||
main_branch: master
|
main_branch: master
|
||||||
target: frontend
|
target: frontend
|
||||||
registry_username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build & push backend
|
- name: Build & push backend
|
||||||
uses: self:captbrick/gitea-actions/docker-build-push@master
|
uses: https://gitea.livingeach.day/captbrick/gitea-actions/docker-build-push@main
|
||||||
with:
|
with:
|
||||||
main_branch: master
|
main_branch: master
|
||||||
target: backend
|
target: backend
|
||||||
registry_username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> `push: 'false'` on the warm-up step means it skips Docker login, push,
|
> `push: 'false'` on the warm-up step means it skips Docker login, push,
|
||||||
@@ -179,12 +169,10 @@ hit `no match for platform in manifest` when pulling), set a single foreign
|
|||||||
platform or a comma-separated list:
|
platform or a comma-separated list:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: self:captbrick/gitea-actions/docker-build-push@master
|
- uses: https://gitea.livingeach.day/captbrick/gitea-actions/docker-build-push@main
|
||||||
with:
|
with:
|
||||||
main_branch: master
|
main_branch: master
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
registry_username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`docker/setup-qemu-action` always runs before the build, so the runner can
|
`docker/setup-qemu-action` always runs before the build, so the runner can
|
||||||
@@ -213,13 +201,15 @@ the local Docker daemon even if that were attempted.)
|
|||||||
| `image_registry` | Container registry used to build the image tag and to log in to; forwarded to `get-next-version` when set, otherwise its default (`gitea.livingeach.day`) is used | no | `''` |
|
| `image_registry` | Container registry used to build the image tag and to log in to; forwarded to `get-next-version` when set, otherwise its default (`gitea.livingeach.day`) is used | no | `''` |
|
||||||
| `image_repository` | Image repository used to build the image tag; forwarded to `get-next-version` when set, otherwise its default (full `owner/repo` path) is used. It is always lowercased before building `IMAGE_TAG`, because Docker repository names must be lowercase | no | `''` |
|
| `image_repository` | Image repository used to build the image tag; forwarded to `get-next-version` when set, otherwise its default (full `owner/repo` path) is used. It is always lowercased before building `IMAGE_TAG`, because Docker repository names must be lowercase | no | `''` |
|
||||||
| `target` | Dockerfile build stage/target (`docker build --target`); also forwarded to `get-next-version` as `image_name` — see [Multiple images from one Dockerfile](#multiple-images-from-one-dockerfile) | no | `''` |
|
| `target` | Dockerfile build stage/target (`docker build --target`); also forwarded to `get-next-version` as `image_name` — see [Multiple images from one Dockerfile](#multiple-images-from-one-dockerfile) | no | `''` |
|
||||||
| `registry_username` | Username (or service principal app ID) used to log in to the registry | yes | |
|
| `image_name` | Optional image name below `image_repository`; when empty, `target` is used | no | `''` |
|
||||||
| `registry_password` | Password (or service principal secret) used to log in to the registry | yes | |
|
| `registry_username` | Username (or service principal app ID) used to log in to the registry | no | `${{ secrets.DOCKER_USER }}` |
|
||||||
|
| `registry_password` | Password (or service principal secret) used to log in to the registry | no | `${{ secrets.DOCKER_PASSWORD }}` |
|
||||||
| `dockerfile` | Path to the Dockerfile to build | no | `Dockerfile` |
|
| `dockerfile` | Path to the Dockerfile to build | no | `Dockerfile` |
|
||||||
| `context` | Docker build context path | no | `.` |
|
| `context` | Docker build context path | no | `.` |
|
||||||
| `push` | Whether to push the built image and create/push a Git tag matching `version_tag`; Docker login also runs when `cache` is enabled | no | `'true'` |
|
| `push` | Whether to push the built image and create/push a Git tag matching `version_tag`; Docker login also runs when `cache` is enabled | no | `'true'` |
|
||||||
| `cache` | Whether to use registry-backed Docker BuildKit cache with branch/base cache refs and detected merge-source cache refs | no | `'true'` |
|
| `cache` | Whether to use registry-backed Docker BuildKit cache with branch/base cache refs and detected merge-source cache refs | no | `'true'` |
|
||||||
| `cache_registry` | Optional registry used for BuildKit cache refs; defaults to the computed `IMAGE_REGISTRY` when empty | no | `''` |
|
| `cache_registry` | Optional registry used for BuildKit cache refs; defaults to the computed `IMAGE_REGISTRY` when empty | no | `''` |
|
||||||
|
| `lfs` | Whether to fetch Git LFS files during checkout | no | `'false'` |
|
||||||
| `platforms` | Comma-separated `docker buildx build --platform` list, e.g. `linux/amd64,linux/arm64` — see [Building for multiple platforms](#building-for-multiple-platforms) | no | `'linux/amd64'` |
|
| `platforms` | Comma-separated `docker buildx build --platform` list, e.g. `linux/amd64,linux/arm64` — see [Building for multiple platforms](#building-for-multiple-platforms) | no | `'linux/amd64'` |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
registry_username:
|
registry_username:
|
||||||
description: Username (or service principal app ID) used to log in to the registry.
|
description: Username (or service principal app ID) used to log in to the registry. Defaults to secrets.DOCKER_USER.
|
||||||
required: true
|
required: false
|
||||||
|
default: ${{ secrets.DOCKER_USER }}
|
||||||
registry_password:
|
registry_password:
|
||||||
description: Password (or service principal secret) used to log in to the registry.
|
description: Password (or service principal secret) used to log in to the registry. Defaults to secrets.DOCKER_PASSWORD.
|
||||||
required: true
|
required: false
|
||||||
|
default: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
dockerfile:
|
dockerfile:
|
||||||
description: Path to the Dockerfile to build.
|
description: Path to the Dockerfile to build.
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
Reference in New Issue
Block a user