chore: add repository config

This commit is contained in:
Alexander Navarro 2024-11-04 15:39:34 -03:00
parent 3beb696eb5
commit bcbd67331b
Signed by untrusted user who does not match committer: anavarro
GPG key ID: 6426043E9FA3E3B5
4 changed files with 219 additions and 1 deletions

View file

@ -0,0 +1,67 @@
name: Publish image
on:
push:
paths:
- 'boxes/**'
workflow_dispatch:
jobs:
generate-matrix:
name: Generate job matrices
runs-on: host
outputs:
boxes: ${{ steps.changed-files.outputs.all_changed_files }}
boxes-count: ${{ steps.changed-files.outputs.all_changed_files_count }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: List changed files
id: changed-files
uses: tj-actions/changed-files@v45.0.3
with:
matrix: true
diff_relative: true
dir_names: true
dir_names_exclude_current_dir: true
dir_names_max_depth: 2
files: boxes/**
- name: Output changes
run: |
echo 'Files changed: ${{ steps.changed-files.outputs.all_changed_files_count }}'
echo 'List: ${{ steps.changed-files.outputs.all_changed_files }}'
create-docker-images:
needs: generate-matrix
runs-on: host
strategy:
matrix:
box: ${{ fromJson(needs.generate-matrix.outputs.boxes) }}
max-parallel: 4
fail-fast: false
if: ${{ needs.generate-matrix.outputs.boxes-count > 0 }}
steps:
- name: Print variables
run: |
echo 'Building image in context: ${{ toJson(matrix) }}'
echo 'Building image in context: ${{ fromJson(needs.generate-matrix.outputs.boxes) }}'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: git.alecodes.page
username: ${{ vars.CONTAINER_REGISTRY_USER }}
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
context: "{{defaultContext}}:${{ matrix.box }}"
tags: |
git.alecodes.page/alecodes/devbox:latest