diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a83d521 --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 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..9ce2d92 --- /dev/null +++ b/Earthfile @@ -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