1
0
mirror of https://github.com/gilbN/theme.park.git synced 2024-07-15 00:57:32 +02:00

Update mods workflow (#504)

* Build all mods on push
This commit is contained in:
GilbN 2023-08-01 11:46:41 +02:00 committed by GitHub
parent c27a1fbea3
commit 2f86f4a35b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,8 +3,10 @@ on:
push: push:
branches: branches:
- master - master
- develop
- testing
paths: paths:
- 'docker-mods/**' - '**/docker-mods/**'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
app: app:
@ -43,6 +45,7 @@ on:
append-tag: append-tag:
required: false required: false
description: 'Append a the tag with "-custom" e.g :radarr-testing' description: 'Append a the tag with "-custom" e.g :radarr-testing'
jobs: jobs:
push_to_ghcr_io: push_to_ghcr_io:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -51,46 +54,47 @@ jobs:
uses: actions/checkout@v3.1.0 uses: actions/checkout@v3.1.0
with: with:
fetch-depth: 0 fetch-depth: 0
- name: get changed files
id: getfile
run: |
echo "files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} docker-mods/| xargs)" >> $GITHUB_ENV
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.1.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GH_PAT }} password: ${{ secrets.GH_PAT }}
- name: find correct directory then build&push - name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: build all on push
if: ${{ github.event_name == 'push' }} if: ${{ github.event_name == 'push' }}
run: | run: |
for i in ${{ env.files }} branch=${{ steps.extract_branch.outputs.branch }}
do
directory="$( echo $i | cut -d'/' -f2 -s )" if [ "$branch" = "master" ]; then
if [ -z "$directory" ]; then branch=""
continue # Skip root dir else
elif [ "$i" == *.md ]; then branch="-$branch"
continue # Skip markdown files fi
elif [ "$i" == *.yml ]; then for dir in docker-mods/*;
continue # Skip YAML files do
fi app="$( echo "$dir" | cut -d'/' -f2 -s )"
docker build docker-mods/$directory --tag ghcr.io/gilbn/theme.park:$directory docker build docker-mods/$app --tag ghcr.io/${{ secrets.GHCR_USER }}/theme.park:$app$branch
docker push ghcr.io/gilbn/theme.park:$directory docker push ghcr.io/${{ secrets.GHCR_USER }}/theme.park:$app$branch
done done
- name: manually build - name: manually build
if: ${{ github.event.inputs.app && github.event.inputs.app != 'build-all-the-mods' }} if: ${{ github.event.inputs.app && github.event.inputs.app != 'build-all-the-mods' }}
run: | run: |
docker build docker-mods/${{ github.event.inputs.app }} --tag ghcr.io/gilbn/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }} docker build docker-mods/${{ github.event.inputs.app }} --tag ghcr.io/${{ secrets.GHCR_USER }}/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }}
docker push ghcr.io/gilbn/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }} docker push ghcr.io/${{ secrets.GHCR_USER }}/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }}
- name: manually build all mods - name: manually build all mods
if: ${{ github.event.inputs.app == 'build-all-the-mods' }} if: ${{ github.event.inputs.app == 'build-all-the-mods' }}
run: | run: |
for dir in docker-mods/*; for dir in docker-mods/*;
do do
app="$( echo "$dir" | cut -d'/' -f2 -s )" app="$( echo "$dir" | cut -d'/' -f2 -s )"
docker build docker-mods/$app --tag ghcr.io/gilbn/theme.park:$app${{ github.event.inputs.append-tag }} docker build docker-mods/$app --tag ghcr.io/${{ secrets.GHCR_USER }}/theme.park:$app${{ github.event.inputs.append-tag }}
docker push ghcr.io/gilbn/theme.park:$app${{ github.event.inputs.append-tag }} docker push ghcr.io/${{ secrets.GHCR_USER }}/theme.park:$app${{ github.event.inputs.append-tag }}
done done
push_to_dockerhub: push_to_dockerhub:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -98,42 +102,42 @@ jobs:
uses: actions/checkout@v3.1.0 uses: actions/checkout@v3.1.0
with: with:
fetch-depth: 0 fetch-depth: 0
- name: get changed files
id: getfile
run: |
echo "files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} docker-mods/| xargs)" >> $GITHUB_ENV
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.1.0
with: with:
username: ${{ secrets.DH_USER }} username: ${{ secrets.DH_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: find correct directory then build&push - name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: build all on push
if: ${{ github.event_name == 'push' }} if: ${{ github.event_name == 'push' }}
run: | run: |
for i in ${{ env.files }} branch=${{ steps.extract_branch.outputs.branch }}
do
directory="$( echo $i | cut -d'/' -f2 -s )" if [ "$branch" = "master" ]; then
if [ -z "$directory" ]; then branch=""
continue # Skip root dir else
elif [ "$i" == *.md ]; then branch="-$branch"
continue # Skip markdown files fi
elif [ "$i" == *.yml ]; then for dir in docker-mods/*;
continue # Skip YAML files do
fi app="$( echo "$dir" | cut -d'/' -f2 -s )"
docker build docker-mods/$directory --tag gilbn/theme.park:$directory docker build docker-mods/$app --tag ${{ secrets.DH_USER }}/theme.park:$app$branch
docker push gilbn/theme.park:$directory docker push ${{ secrets.DH_USER }}/theme.park:$app$branch
done done
- name: manually build - name: manually build
if: ${{ github.event.inputs.app && github.event.inputs.app != 'build-all-the-mods' }} if: ${{ github.event.inputs.app && github.event.inputs.app != 'build-all-the-mods' }}
run: | run: |
docker build docker-mods/${{ github.event.inputs.app }} --tag gilbn/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }} docker build docker-mods/${{ github.event.inputs.app }} --tag ${{ secrets.DH_USER }}/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }}
docker push gilbn/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }} docker push ${{ secrets.DH_USER }}/theme.park:${{ github.event.inputs.app }}${{ github.event.inputs.append-tag }}
- name: manually build all mods - name: manually build all mods
if: ${{ github.event.inputs.app == 'build-all-the-mods' }} if: ${{ github.event.inputs.app == 'build-all-the-mods' }}
run: | run: |
for dir in docker-mods/*; for dir in docker-mods/*;
do do
app="$( echo "$dir" | cut -d'/' -f2 -s )" app="$( echo "$dir" | cut -d'/' -f2 -s )"
docker build docker-mods/$app --tag gilbn/theme.park:$app${{ github.event.inputs.append-tag }} docker build docker-mods/$app --tag ${{ secrets.DH_USER }}/theme.park:$app${{ github.event.inputs.append-tag }}
docker push gilbn/theme.park:$app${{ github.event.inputs.append-tag }} docker push ${{ secrets.DH_USER }}/theme.park:$app${{ github.event.inputs.append-tag }}
done done