-
Notifications
You must be signed in to change notification settings - Fork 16
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
za419
wants to merge
8
commits into
kenellorando:master
Choose a base branch
from
za419:create-build-workflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15b0ab2
Add a workflow for automated image build and push
za419 73e8634
Use exit codes explicitly
za419 14a4070
More logic updates
za419 865f6c3
Use -eqs
za419 ecdcac6
Give in and use ifs
za419 22b8931
Move -t setting into each build step
za419 c7a6be7
Rename variable
za419 7e530a8
Remove dead code
za419 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 }} | ||
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.