Skip to content

more workflow debugs #7

more workflow debugs

more workflow debugs #7

Workflow file for this run

name: Add-on CI/CD
on:
push:
branches:
- main
- 'feature/**'
pull_request:
branches:
- main
jobs:
discover:
name: Discover Add-ons
runs-on: ubuntu-latest
outputs:
addon_dirs: ${{ steps.folders.outputs.addon_dirs }}
steps:
- name: Checkout code from GitHub
uses: actions/checkout@v2
- name: Find add-on directories
id: folders
run: |
ADDON_DIRS=$(find addons -mindepth 1 -maxdepth 1 -type d | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "::set-output name=addon_dirs::$ADDON_DIRS"
- name: Debug - List directories
run: |
echo "Found add-on directories:"
echo "${{ steps.folders.outputs.addon_dirs }}"
information:
name: Gather add-on information
needs: discover
runs-on: ubuntu-latest
strategy:
matrix:
folder: ${{ fromJson(needs.discover.outputs.addon_dirs) }}
outputs:
architectures: ${{ steps.information.outputs.architectures }}
build: ${{ steps.information.outputs.build }}
name: ${{ steps.information.outputs.name }}
slug: ${{ steps.override.outputs.slug }}
target: ${{ steps.information.outputs.target }}
steps:
- name: Checkout code from GitHub
uses: actions/checkout@v2
- name: Debug - List directories after checkout
run: |
ls -R
- name: Debug - Verify path
run: |
echo "Checking path: ${{ matrix.folder }}/config.json"
if [[ -f "${{ matrix.folder }}/config.json" ]]; then
echo "Config file exists: ${{ matrix.folder }}/config.json"
else
echo "Config file does not exist: ${{ matrix.folder }}/config.json"
fi
- name: Debug - Show config.json content
run: |
echo "Content of ${{ matrix.folder }}/config.json:"
cat "${{ matrix.folder }}/config.json"
- name: Run add-on information action
id: information
uses: frenck/[email protected]
with:
path: "${{ matrix.folder }}/config.json"
- 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:
name: Lint Add-on
needs: information
runs-on: ubuntu-latest
strategy:
matrix:
folder: ${{ fromJson(needs.discover.outputs.addon_dirs) }}
steps:
- name: Checkout code from GitHub
uses: actions/checkout@v2
- name: Run Add-on Lint
uses: frenck/[email protected]
with:
community: true
path: "${{ matrix.folder }}"
- name: Run Hadolint
uses: brpaz/[email protected]
with:
dockerfile: "${{ matrix.folder }}/Dockerfile"
- name: Run JQ
run: |
shopt -s globstar
cat **/*.json | jq '.'
- name: Run Shellcheck
uses: ludeeus/[email protected]
env:
SHELLCHECK_OPTS: -s bash
- name: Run YAMLLint
uses: frenck/[email protected]
- name: Run Prettier
uses: creyD/[email protected]
with:
prettier_options: --write **/*.{json,js,md,yaml}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build and Push Docker image
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
folder: ${{ fromJson(needs.discover.outputs.addon_dirs) }}
architecture: [amd64, armhf, armv7, aarch64, i386]
steps:
- name: Checkout code from GitHub
uses: actions/checkout@v2
- name: Set up build cache
id: cache
uses: actions/cache@v2
with:
path: /tmp/.docker-cache
key: docker-${{ matrix.architecture }}-${{ github.sha }}
restore-keys: |
docker-${{ matrix.architecture }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Compose build flags
id: flags
run: |
echo "date=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_ENV"
from=$(yq --no-colors eval ".build_from.${{ matrix.architecture }}" "${{ matrix.folder }}/config.json")
echo "from=${from}" >> "$GITHUB_ENV"
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then
echo "platform=linux/amd64" >> "$GITHUB_ENV"
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then
echo "platform=linux/386" >> "$GITHUB_ENV"
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then
echo "platform=linux/arm/v6" >> "$GITHUB_ENV"
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then
echo "platform=linux/arm/v7" >> "$GITHUB_ENV"
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then
echo "platform=linux/arm64/v8" >> "$GITHUB_ENV"
else
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}"
exit 1
env:
GITHUB_ENV: ${{ github.env }}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./${{ matrix.folder }}
file: ./${{ matrix.folder }}/Dockerfile
push: true
tags: |
amateurgod/${{ matrix.folder }}:latest
amateurgod/${{ matrix.folder }}:${{ needs.information.outputs.version }}
cache-from: type=local,src=/tmp/.docker-cache
cache-to: type=local,mode=max,dest=/tmp/.docker-cache-new
publish:
name: Publish to Repository
needs: build
runs-on: ubuntu-latest
steps:
- name: Dispatch repository update signal
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: ${{ github.repository_owner }}/repository
event-type: update
client-payload: >
{
"addon": "${{ needs.information.outputs.slug }}",
"name": "${{ needs.information.outputs.name }}",
"repository": "${{ github.repository }}",
"version": "${{ needs.information.outputs.version }}"
}