Skip to content

Commit

Permalink
Add Earthfile and release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cyxou committed Feb 4, 2024
1 parent 99ebb4d commit 3c3d038
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release

on:
workflow_dispatch:
push:
paths-ignore:
- './*.md'
tags:
- 'v[0-9]+.[0-9]+.*'
branches:
- master

env:
DOCKER_USERNAME: ${{ vars.GHCR_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.GHCR_TOKEN }}
FORCE_COLOR: 1

jobs:
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Docker Login
run: docker login ghcr.io/librepod --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD"

- name: Download latest earthly
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.3/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"

- 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: Build and push docker image
run: |
earthly --ci --push +build \
--TARGET_DOCKER_REGISTRY=quay.io/librepod \
--ARGOCD_TAG=v2.9.6 \
--ARGOCD_BASE_IMAGE=quay.io/argoproj/argocd
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.arg
.secret
32 changes: 32 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
VERSION 0.7

ARG --global TARGET_DOCKER_REGISTRY

build:
ARG ARGOCD_TAG=v2.9.6
ARG ARGOCD_BASE_IMAGE=quay.io/argoproj/argocd
FROM ${ARGOCD_BASE_IMAGE}:${ARGOCD_TAG}

# Switch to root for the ability to perform install
USER root

RUN apt-get update

# Setup non-root user
WORKDIR /home/argocd

RUN apt-get update && apt-get --no-install-recommends --yes install \
jq curl \
&& curl -L -o yq_linux_amd64.tar.gz https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64.tar.gz \
&& tar xzf ./yq_linux_amd64.tar.gz \
&& chmod +x ./yq_linux_amd64 && mv ./yq_linux_amd64 /usr/local/bin/yq \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g pnpm cdk8s \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Switch back to non-root user
USER 999

SAVE IMAGE --push ${TARGET_DOCKER_REGISTRY}/argocd-cdk8s:$ARGOCD_TAG

0 comments on commit 3c3d038

Please sign in to comment.