62 lines
2.0 KiB
YAML
62 lines
2.0 KiB
YAML
name: "🐳 Publish Docker"
|
|
on:
|
|
workflow_call:
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING: 1
|
|
outputs:
|
|
version: ${{ steps.get_version.outputs.version }}
|
|
short_sha: ${{ steps.get_commit.outputs.sha_short }}
|
|
steps:
|
|
- name: Setup Depot CLI
|
|
uses: depot/setup-action@v1
|
|
|
|
- name: ⬇️ Checkout repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: 🆚 Get the version
|
|
id: get_version
|
|
run: |
|
|
IMAGE_TAG="${GITHUB_REF#refs/tags/}"
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
if [[ $IMAGE_TAG == v.docker.* ]]; then
|
|
ORIGINAL_VERSION="${IMAGE_TAG#v.docker.}"
|
|
IMAGE_TAG="v${ORIGINAL_VERSION}"
|
|
elif [[ $IMAGE_TAG == build-* ]]; then
|
|
IMAGE_TAG="${IMAGE_TAG#build-}"
|
|
fi
|
|
echo "IMAGE_TAG=${IMAGE_TAG}"
|
|
elif [[ $GITHUB_REF == refs/heads/main ]]; then
|
|
# Handle main branch specifically
|
|
IMAGE_TAG="main"
|
|
echo "IMAGE_TAG=${IMAGE_TAG}"
|
|
else
|
|
echo "Invalid reference: ${GITHUB_REF}"
|
|
exit 1
|
|
fi
|
|
echo "::set-output name=version::${IMAGE_TAG}"
|
|
- name: 🔢 Get the commit hash
|
|
id: get_commit
|
|
run: |
|
|
echo ::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c1-7)
|
|
|
|
- name: 🐙 Login to GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: 🐳 Build image and push to GitHub Container Registry
|
|
uses: depot/build-push-action@v1
|
|
with:
|
|
file: ./docker/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
ghcr.io/triggerdotdev/trigger.dev:${{ steps.get_version.outputs.version }}
|
|
push: true
|