-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
13,758 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
earthfiles: | ||
description: | | ||
A JSON list of Earthfile paths+targets to use for publishing | ||
required: true | ||
type: string | ||
forge_version: | ||
description: | | ||
The version of the forge CLI to install (use 'local' for testing) | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
run: | ||
name: ${{ matrix.earthfile }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
earthfile: ${{ fromJson(inputs.earthfiles) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup CI | ||
uses: ./forge/actions/setup | ||
with: | ||
forge_version: ${{ inputs.forge_version }} | ||
- name: Run | ||
id: run | ||
uses: ./forge/actions/run | ||
with: | ||
path: ${{ matrix.earthfile }} | ||
- name: Get image and project | ||
id: image | ||
if: github.ref_name == github.event.repository.default_branch | ||
run: | | ||
EARTHFILE='${{ matrix.earthfile }}' | ||
PROJECT="${EARTHFILE%+*}" | ||
TARGET="${EARTHFILE#*+}" | ||
RESULT='${{ steps.run.outputs.result }}' | ||
# If the path to the project is just ".", then we omit it | ||
if [[ "$PROJECT" == "." ]]; then | ||
EARTHFILE="+$TARGET" | ||
fi | ||
IMAGE="$(echo "$RESULT" | jq -r ".images[\"$EARTHFILE\"]")" | ||
if [[ "$IMAGE" == "null" ]]; then | ||
echo "::error file=${PROJECT}/Earthfile::No images produced. Cannot publish." | ||
exit 1 | ||
fi | ||
echo "image=$IMAGE" >> $GITHUB_OUTPUT | ||
echo "project=$PROJECT" >> $GITHUB_OUTPUT | ||
- name: Publish | ||
uses: ./forge/actions/publish | ||
if: github.ref_name == github.event.repository.default_branch | ||
with: | ||
image: ${{ steps.image.outputs.image }} | ||
project: ${{ steps.image.outputs.project }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,11 @@ global: { | |
|
||
github: registry: "ghcr.io" | ||
} | ||
tagging: { | ||
aliases: { | ||
forge: "forge/cli" | ||
} | ||
strategy: "commit" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Publish Action | ||
|
||
The publish action pushes Docker images to remote registries using settings from a project's blueprint file. | ||
It automatically handles the configured tagging strategy as well as properly handling git tags. | ||
|
||
## Usage | ||
|
||
```yaml | ||
name: Run Publish | ||
on: | ||
push: | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | ||
uses: input-output-hk/catalyst-forge/forge/actions/setup@master | ||
- name: Publish | ||
uses: input-output-hk/catalyst-forge/forge/actions/discover@master | ||
with: | ||
project: ./my/project/path | ||
container: container:tag | ||
``` | ||
The given project _must_ have a blueprint at the root of the path which, at the very least, declares a project name. | ||
By default, the `container` property of a project uses the project name if not specified. | ||
Alternatively, the `container` field can be set explicitly. | ||
The `container` input to the publish action _must_ match an existing container image in the local Docker daemon. | ||
The given container name is discarded and the value of the `container` field is used for naming the container. | ||
|
||
The final tags the container is published with are determined by the blueprint configuration and the git context: | ||
|
||
- The `global.ci.tagging.strategy` configuration property determines the default tag given to all images | ||
- If the git context contains a git tag, then the publish action may or may not publish an image with the tag: | ||
- If the tag is in the "mono-repo" style (`some/path/v1.0.0`) | ||
- If the path (`some/path`) matches an alias in `global.ci.tagging.strategy.aliases`, and the value of the alias matches the | ||
given project, then the tag is used | ||
- If the path does not match an alias, but the path itself matches the given project, then the tag is used | ||
- If none of the above are true, the tag is assumed to be for a different project and is skipped | ||
- If the tag is any other style, it's used as-is (no modifications) | ||
|
||
The following table provides an example of how the git tag is used in various contexts: | ||
|
||
| Project | Git tag | Aliases | Image tag | | ||
| ------------- | -------------------- | ------------------------ | --------- | | ||
| `my/cool/cli` | None | None | Not used | | ||
| `my/cool/cli` | `v1.0.0` | None | `v1.0.0` | | ||
| `my/cool/cli` | `my/v1.0.0` | None | Not used | | ||
| `my/cool/cli` | `my/cool/cli/v1.0.0` | None | `v1.0.0` | | ||
| `my/cool/cli` | `cli/v1.0.0` | `{"cli": "my/cool/cli"}` | `v1.0.0` | | ||
|
||
After processing any additional tags, the container is retagged with each generated tag and pushed to all registries configured in | ||
`global.ci.registries`. | ||
The publish action assumes the local Docker daemon is already authenticated to any configured registries. | ||
|
||
## Inputs | ||
|
||
| Name | Description | Required | Default | | ||
| ------- | ------------------------------------------------ | -------- | ------- | | ||
| project | The relative path to the project (from git root) | Yes | N/A | | ||
| image | The existing container image to publish | Yes | N/A | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Publish | ||
description: Publish container images | ||
inputs: | ||
project: | ||
description: The path to the project | ||
required: true | ||
image: | ||
description: The full image name (name:tag) to publish | ||
required: true | ||
|
||
runs: | ||
using: node20 | ||
main: dist/index.js |
Oops, something went wrong.