Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create build workflow #269

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: "Docker Build and Push"

on:
release:
types: ["published"]
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:
inputs:
push:
type: boolean
description: "Push image after build"
default: false
tags:
type: string
description: "Tags to apply to built image in addition to commit ID (separated by spaces)"
default: ""

jobs:
build:
name: Build and push docker images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare tag list (manual trigger)
if: github.event_name == 'workflow_dispatch'
run: |
declare -a tags
for tag in ${{ github.inputs.tags }}
do
tags+=("$tag")
done
tags+=("$(git rev-parse --short HEAD)")
echo "tags=\"${tags[@]}\"" >> $GITHUB_ENV
- name: Prepare tag list (push trigger)
if: github.event_name != 'workflow_dispatch'
run: |
release=$(git tag --points-at HEAD)
echo "tags=\"latest $(git rev-parse --short HEAD)\" $release" >> $GITHUB_ENV
- name: Check push configuration
run: |
auto=1
manual=1
release=1

if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/main" ]
then
auto=0
fi

if [ "${{ github.inputs.push }}" = "true" ]
then
manual=0
fi

if [ "${{ github.event_name }}" = "release" ]
then
release=0
fi

push=`[[ $auto -eq 0 || $manual -eq 0 || $release -eq 0 ]] && echo 'true' || echo 'false'`
echo "do_push=$push" >> $GITHUB_ENV
- name: Build Cadence server image
run: |
IMAGE=kenellorando/cadence
declare -a flags
for tag in "${{ env.tags }}"
do
flags+=("-t $IMAGE:$tag")
done
docker build ${flags[@]} -f src/cadence.Dockerfile src
- name: Build icecast2 image
run: |
IMAGE=kenellorando/cadence_icecast2
declare -a flags
for tag in "${{ env.tags }}"
do
flags+=("-t $IMAGE:$tag")
done
docker build ${flags[@]} -f src/icecast2.Dockerfile src
- name: Build liquidsoap image
run: |
IMAGE=kenellorando/cadence_liquidsoap
declare -a flags
for tag in "${{ env.tags }}"
do
flags+=("-t $IMAGE:$tag")
done
docker build ${flags[@]} -f src/liquidsoap.Dockerfile src
- name: Login to Docker Hub
if: env.push == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These secrets will need to be added to this repository for this bit to work properly.

password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Push Cadence images
if: env.push == 'true'
run: |
sha=$(git rev-parse --short HEAD)
docker push --all-tags kenellorando/cadence:$sha
docker push --all-tags kenellorando/cadence_icecast2:$sha
docker push --all-tags kenellorando/cadence_liquidsoap:$sha
Loading