Create release-package.yml #1
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
# Taken from the Earthly documentation | |
# https://docs.earthly.dev/ci-integration/vendor-specific-guides/gh-actions-integration | |
name: Publish slim image | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
FORCE_COLOR: 1 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Checkout LFS objects | |
run: git lfs checkout | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Put back the git branch into git (Earthly uses it for tagging) | |
run: | | |
branch="" | |
if [ -n "$GITHUB_HEAD_REF" ]; then | |
branch="$GITHUB_HEAD_REF" | |
else | |
branch="${GITHUB_REF##*/}" | |
fi | |
git checkout -b "$branch" || true | |
- name: Download latest earthly | |
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.6.10/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" | |
- name: Earthly version | |
run: earthly --version | |
- name: Run build | |
run: | | |
branch="" | |
if [ -n "$GITHUB_HEAD_REF" ]; then | |
branch="$GITHUB_HEAD_REF" | |
else | |
branch="${GITHUB_REF##*/}" | |
fi | |
earthly --build-arg tag="$GITHUB_SHA" --ci --push +github | |
if [ "$branch" = "main" ]; then | |
earthly --build-arg tag="latest" --ci --push +github | |
fi |