Skip to content

Commit

Permalink
refactor: publish action now sets container name/tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Sep 10, 2024
1 parent c904677 commit de8d7fb
Show file tree
Hide file tree
Showing 12 changed files with 29,850 additions and 891 deletions.
41 changes: 15 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
description: Optional Earthly token used to login to Earthly cloud during local builds of Forge CLI
required: false

env:
CONTAINER: container
TAG: tag

jobs:
run:
name: ${{ matrix.earthfile }}
Expand All @@ -31,37 +35,22 @@ jobs:
with:
earthly_token: ${{ secrets.earthly_token }}
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
- name: Parse Earthfile reference
id: parse
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 ".\"linux/amd64\".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
echo "target=$TARGET" >> $GITHUB_OUTPUT
- name: Run
id: run
uses: ./forge/actions/run
with:
args: --container ${{ env.CONTAINER }} --tag ${{ env.TAG }}
path: ${{ matrix.earthfile }}
- 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 }}
image: "${{ env.CONTAINER }}:${{ env.TAG }}"
project: ${{ steps.parse.outputs.project }}
Loading

0 comments on commit de8d7fb

Please sign in to comment.