Merge pull request #10 from sviete/araczkowski-patch-1 #78
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
--- | |
name: CI | |
# yamllint disable-line rule:truthy | |
on: | |
push: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
workflow_dispatch: | |
jobs: | |
information: | |
name: Gather add-on information | |
runs-on: ubuntu-latest | |
outputs: | |
architectures: ${{ steps.information.outputs.architectures }} | |
base_image_signer: ${{ steps.information.outputs.codenotary_base_image }} | |
build: ${{ steps.information.outputs.build }} | |
description: ${{ steps.information.outputs.description }} | |
name: ${{ steps.information.outputs.name }} | |
slug: ${{ steps.override.outputs.slug }} | |
target: ${{ steps.information.outputs.target }} | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run add-on information action | |
id: information | |
uses: frenck/action-addon-information@v1.4.2 | |
- name: 🚀 Process possible slug override | |
id: override | |
run: | | |
slug="${{ steps.information.outputs.slug }}" | |
if [[ ! -z "${{ inputs.slug }}" ]]; then | |
slug="${{ inputs.slug }}" | |
fi | |
echo "slug=$slug" >> $GITHUB_OUTPUT | |
lint-addon: | |
name: Lint Add-on | |
needs: | |
- information | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run Add-on Lint | |
uses: frenck/action-addon-linter@v2.13 | |
with: | |
community: true | |
path: "./${{ needs.information.outputs.target }}" | |
lint-hadolint: | |
name: Hadolint | |
needs: | |
- information | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run Hadolint | |
uses: brpaz/hadolint-action@v1.5.0 | |
with: | |
dockerfile: "./${{ needs.information.outputs.target }}/Dockerfile" | |
lint-json: | |
name: JSON Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run JQ | |
run: | | |
shopt -s globstar | |
cat **/*.json | jq '.' | |
lint-markdown: | |
name: MarkdownLint | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run mdl | |
uses: actionshub/markdownlint@v3.1.3 | |
lint-shellcheck: | |
name: Shellcheck | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run Shellcheck | |
uses: ludeeus/action-shellcheck@2.0.0 | |
env: | |
SHELLCHECK_OPTS: -s bash | |
lint-yamllint: | |
name: YAMLLint | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run YAMLLint | |
uses: frenck/action-yamllint@v1.4 | |
lint-prettier: | |
name: Prettier | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🚀 Run Prettier | |
uses: creyD/prettier_action@v4.3 | |
with: | |
prettier_options: --write **/*.{json,js,md,yaml} | |
build: | |
name: Build ${{ matrix.architecture }} | |
needs: | |
- information | |
- lint-addon | |
- lint-hadolint | |
- lint-json | |
- lint-markdown | |
- lint-prettier | |
- lint-shellcheck | |
- lint-yamllint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
architecture: ${{ fromJson(needs.information.outputs.architectures) }} | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v3 | |
- name: 🏗 Set up QEMU | |
uses: docker/setup-qemu-action@v2.2.0 | |
- name: 🏗 Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2.10.0 | |
- name: ℹ️ Compose build flags | |
id: flags | |
run: | | |
echo "date=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT | |
from=$(yq --no-colors eval ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}") | |
echo "from=$from" >> $GITHUB_OUTPUT | |
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then | |
echo "platform=linux/amd64" >> $GITHUB_OUTPUT | |
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then | |
echo "platform=linux/386" >> $GITHUB_OUTPUT | |
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then | |
echo "platform=linux/arm/v6" >> $GITHUB_OUTPUT | |
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then | |
echo "platform=linux/arm/v7" >> $GITHUB_OUTPUT | |
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then | |
echo "platform=linux/arm64/v8" >> $GITHUB_OUTPUT | |
else | |
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}" | |
exit 1 | |
fi | |
- name: ⤵️ Download base image | |
run: docker pull "${{ steps.flags.outputs.from }}" | |
- name: ✅ Verify authenticity of base image | |
if: needs.information.outputs.base_image_signer != 'null' | |
uses: codenotary/cas-authenticate-docker-image-github-action@main | |
with: | |
asset: docker://${{ steps.flags.outputs.from }} | |
signerID: ${{ needs.information.outputs.base_image_signer }} | |
- name: 🚀 Build | |
uses: docker/build-push-action@v4.1.1 | |
with: | |
push: false | |
context: ${{ needs.information.outputs.target }} | |
file: ${{ needs.information.outputs.target }}/Dockerfile | |
cache-from: type=gha,scope=${{ needs.information.outputs.slug }}-${{ matrix.architecture }} | |
cache-to: type=gha,mode=max,scope=${{ needs.information.outputs.slug }}-${{ matrix.architecture }} | |
platforms: ${{ steps.flags.outputs.platform }} | |
build-args: | | |
BUILD_ARCH=${{ matrix.architecture }} | |
BUILD_DATE=${{ steps.flags.outputs.date }} | |
BUILD_DESCRIPTION=${{ needs.information.outputs.description }} | |
BUILD_FROM=${{ steps.flags.outputs.from }} | |
BUILD_NAME=${{ needs.information.outputs.name }} | |
BUILD_REF=${{ github.sha }} | |
BUILD_REPOSITORY=${{ github.repository }} | |
BUILD_VERSION=edge |