🔍 Continuous integration #429
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
--- | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: | |
- 'master' | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
branches: | |
- 'master' | |
release: | |
types: | |
- 'created' | |
schedule: | |
# Every Tuesday at 03:10 | |
- cron: '10 5 * * 2' | |
name: 🔍 Continuous integration | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os_name: ['alpine'] | |
steps: | |
- name: 📦 Install goss | |
uses: e1himself/[email protected] | |
- name: 📦 Check out the codebase | |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4 | |
with: | |
fetch-depth: 0 | |
- name: 🌎 Set environment variables | |
env: | |
IMAGE_NAMESPACE: wayofdev/build-deps | |
TEMPLATE: ${{ matrix.os_name }} | |
run: | | |
export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \ | |
&& { \ | |
echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \ | |
echo "TEMPLATE=${TEMPLATE}"; \ | |
echo "VERSION=${RELEASE_VERSION:1}"; \ | |
} >> "$GITHUB_ENV" | |
- name: 🤖 Generate dist files | |
run: make generate | |
- name: 🐳 Define docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE_NAMESPACE }} | |
tags: | | |
type=raw,event=branch,value=latest | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
flavor: | | |
latest=false | |
prefix=${{ matrix.os_name }}- | |
- name: 🔑 Login to docker-hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
### For Cross Platform OSX builds uncomment these lines | |
- name: 🖥️ Set up QEMU | |
uses: docker/[email protected] | |
with: | |
platforms: arm64 | |
- name: 🚀 Set up Docker BuildX | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: 🏷️ Set tag for docker release image | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
run: | | |
echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-${{ env.VERSION }}" >> "$GITHUB_ENV" | |
- name: 🏷️ Set tag for docker master image | |
if: success() && ! startsWith(github.ref, 'refs/tags/') | |
run: | | |
echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest" >> "$GITHUB_ENV" | |
- name: 🛠️ Build and export to docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./dist/${{ env.TEMPLATE }} | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=registry,ref=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest | |
cache-to: type=inline | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: 🧪 Test docker image | |
run: | | |
export IMAGE_TAG=${{ env.IMAGE_TAG }}; make test | |
- name: 📤 Push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./dist/${{ env.TEMPLATE }} | |
### For Cross Platform OSX builds uncomment these lines | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=registry,ref=${{ env.IMAGE_TAG }} | |
cache-to: type=inline | |
... |