From d2a024421c68874687f373d8f3be01933fb196ed Mon Sep 17 00:00:00 2001 From: Alex Sukhov Date: Sun, 4 Feb 2024 19:41:19 +0300 Subject: [PATCH] Add Earthfile and release workflow --- .github/workflows/release.yaml | 50 ++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ Earthfile | 33 ++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .gitignore create mode 100644 Earthfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..721074f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,50 @@ +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: 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: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - 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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a48f1c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.arg +.secret diff --git a/Earthfile b/Earthfile new file mode 100644 index 0000000..6c21a89 --- /dev/null +++ b/Earthfile @@ -0,0 +1,33 @@ +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_21.x | bash - \ + && apt-get install -y nodejs \ + && npm install -g pnpm cdk8s-cli \ + && 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