Skip to content

chore(deps): update actions/checkout digest to a5ac7e5 #463

chore(deps): update actions/checkout digest to a5ac7e5

chore(deps): update actions/checkout digest to a5ac7e5 #463

Workflow file for this run

name: Build and Publish
on:
workflow_dispatch:
push:
tags: [v*]
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
env:
MIX_ENV: prod
KUBECONFIG: /home/runner/.kube/config
jobs:
build_container_image:
runs-on: ubuntu-latest
concurrency:
group: publish
permissions:
packages: write
contents: write
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Parse .tool-versions
id: versions
run: |
while IFS= read -r line; do
NAME="$(echo $line | cut -d' ' -f1)"
VALUE=$(echo $line | cut -d' ' -f2-)
echo "$NAME=$VALUE" >> $GITHUB_OUTPUT
done < .tool-versions
- name: Get hexpm Docker Image Tags
id: get-images
run: |
ERLANG_ALPINE=$(curl --request GET \
--url "https://registry.hub.docker.com/v2/namespaces/hexpm/repositories/erlang/tags?name=${{ steps.versions.outputs.erlang }}-alpine&page_size=25&ordering=name" \
| jq -r ".results[0].name")
ELIXIR_ALPINE=${{ steps.versions.outputs.elixir }}-erlang-${ERLANG_ALPINE}
echo "erlang=hexpm/erlang:$ERLANG_ALPINE" >> $GITHUB_OUTPUT
echo "elixir=hexpm/elixir:$ELIXIR_ALPINE" >> $GITHUB_OUTPUT
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare variables
id: prepare_vars
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG=${{ github.ref_name }}
else
TAG=dev
fi
echo "cache_src=ghcr.io/${{ github.repository }}:dev" >> $GITHUB_OUTPUT
echo "e2e_image=ghcr.io/${{ github.repository }}:e2e" >> $GITHUB_OUTPUT
echo "dest_image=ghcr.io/${{ github.repository }}:${TAG#v}" >> $GITHUB_OUTPUT
- name: Build E2E Image
uses: docker/build-push-action@v5
id: build_and_push_e2e
with:
push: false
load: true
tags: ${{ steps.prepare_vars.outputs.e2e_image }}
cache-from: type=registry,ref=${{ steps.prepare_vars.outputs.cache_src }}
cache-to: type=inline
build-args: |
ERLANG_IMAGE=${{ steps.get-images.outputs.erlang }}
ELIXIR_IMAGE=${{ steps.get-images.outputs.elixir }}
- uses: engineerd/setup-kind@v0.5.0
id: kind
with:
version: v0.20.0
name: kompost-test
config: ./test/integration/kind-cluster.yml
- name: Setup elixir
id: beam
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict
install-rebar: true
install-hex: true
- name: Retrieve Deps to Cache
uses: actions/cache/restore@v4
id: deps-folder-cache-test-restore
with:
path: deps
key: ${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-deps-build-and-publish-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
- name: Retrieve Build Folder from Cache
uses: actions/cache/restore@v4
id: build-folder-cache-restore
with:
path: _build
key: ${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-build-build-and-publish-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
- name: Compile app
run: |
mix deps.get
MIX_ENV=test mix compile
MIX_ENV=prod mix compile
- name: Save Deps to Cache
uses: actions/cache/save@v4
id: deps-folder-cache-test-save
with:
path: deps
key: ${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-deps-build-and-publish-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
- name: Save Build Folder to Cache
uses: actions/cache/save@v4
id: build-folder-cache-save
with:
path: _build
key: ${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-build-build-and-publish-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
- name: Run e2e tests
id: run-e2e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
kubectl create ns kompost
MIX_ENV=test mix kompost.gen.manifest
kind load docker-image --name kompost-test "${{ steps.prepare_vars.outputs.e2e_image }}"
MIX_ENV=test mix kompost.gen.periphery
kubectl config use-context kind-kompost-test
MIX_ENV=prod mix kompost.gen.manifest --image "${{ steps.prepare_vars.outputs.e2e_image }}" --out - | kubectl apply -f -
echo "Waiting for kompost pods to get ready"
kubectl wait pods -n kompost -l k8s-app=kompost --for condition=Ready --timeout=300s
MIX_ENV=test POSTGRES_HOST=postgres.postgres.svc.cluster.local TEMPORAL_HOST=temporal.temporal.svc.cluster.local mix coveralls.github --include integration --include e2e --no-start
- name: Logs
if: steps.run-e2e.outcome == 'failure' && failure()
run: |
kubectl logs -n kompost -c init-certificates -l k8s-app=kompost --since=1h
kubectl logs -n kompost -c kompost -l k8s-app=kompost --since=1h
- name: Build and push
uses: docker/build-push-action@v5
id: build_and_push
with:
push: ${{ github.ref_type == 'tag' }}
tags: "${{ steps.prepare_vars.outputs.dest_image }},${{ steps.prepare_vars.outputs.cache_src }},ghcr.io/${{ github.repository }}:latest"
platforms: linux/amd64,linux/arm64/v8,linux/arm
cache-from: type=registry,ref=${{ steps.prepare_vars.outputs.cache_src }}
cache-to: type=inline
build-args: |
ERLANG_IMAGE=${{ steps.get-images.outputs.erlang }}
ELIXIR_IMAGE=${{ steps.get-images.outputs.elixir }}
- name: Prepare release notes
if: github.ref_type == 'tag'
run: |
csplit -s CHANGELOG.md "/^## /" {1}
cat xx01 > release_notes.md
- name: build manifest
if: github.ref_type == 'tag'
run: |
MIX_ENV=prod mix kompost.gen.manifest --image "${{ steps.prepare_vars.outputs.dest_image }}" --namespace kompost -o manifest$.yaml
- name: release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
id: create_release
with:
files: |
manifest.yaml
draft: false
prerelease: false
name: ${{ github.ref_name }}
tag_name: ${{ github.ref }}
body_path: release_notes.md
env:
GITHUB_TOKEN: ${{ github.token }}