Skip to content

Commit

Permalink
Merge pull request #150 from kouprlabs/ci/manually-trigger-build
Browse files Browse the repository at this point in the history
ci: removed run on pull request, refactor tagging
  • Loading branch information
dsonck92 authored Jul 10, 2024
2 parents f687be6 + 91dd59e commit 257c828
Show file tree
Hide file tree
Showing 7 changed files with 238 additions and 79 deletions.
46 changes: 34 additions & 12 deletions .github/workflows/build-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,38 @@ name: Build and Push voltaserve/api

on:
workflow_dispatch:
inputs:
branch:
required: false
default: ""
type: string
description: Override code checkout branch (e.g. "feature/branch")
push:
branches:
- main
paths:
- "api/**"
tags:
- 'v*'
pull_request:
branches:
- main
paths:
- "api/**"

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Prepare input branch
if: ${{ github.event.inputs.branch != "" }}
run: echo "branch=refs/heads/${{ github.event.inputs.branch }}" >> $GITHUB_ENV

- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ env.branch || github.ref }}

- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64, amd64

- name: Extract tag that triggered this action
if: ${{ github.ref_type == 'tag' }}
run: |
TAG=${{ github.ref_name }}
echo "TRIMMED_TAG=${TAG#v}" >> $GITHUB_ENV
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -52,10 +53,31 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create tag list matching semver from executing tag
if: ${{ github.ref_type == 'tag' }}
run: |
name="voltaserve/api"
version="${{ github.ref_name }}"
version="${version#v}"
IFS='.' read -r -a parts <<< "$version"
TAGS="$name:$version"
for ((i=${#parts[@]}-1; i>0; i--)); do
tag=$(IFS='.'; echo "${parts[*]:0:$i}")
TAGS+=",$name:$tag"
done
TAGS+=",$name:latest"
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: Set the tag on wokflow dispatch
if: ${{ github.ref_type != 'tag' }}
run: echo "TAGS=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: ./api
push: true
tags: voltaserve/api:${{ env.TRIMMED_TAG || 'latest' }}
tags: ${{ env.TAGS }}
platforms: linux/amd64,linux/arm64
46 changes: 34 additions & 12 deletions .github/workflows/build-conversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,38 @@ name: Build and Push voltaserve/conversion

on:
workflow_dispatch:
inputs:
branch:
required: false
default: ""
type: string
description: Override code checkout branch (e.g. "feature/branch")
push:
branches:
- main
paths:
- "conversion/**"
tags:
- 'v*'
pull_request:
branches:
- main
paths:
- "conversion/**"

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Prepare input branch
if: ${{ github.event.inputs.branch != "" }}
run: echo "branch=refs/heads/${{ github.event.inputs.branch }}" >> $GITHUB_ENV

- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ env.branch || github.ref }}

- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64, amd64

- name: Extract tag that triggered this action
if: ${{ github.ref_type == 'tag' }}
run: |
TAG=${{ github.ref_name }}
echo "TRIMMED_TAG=${TAG#v}" >> $GITHUB_ENV
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -52,10 +53,31 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create tag list matching semver from executing tag
if: ${{ github.ref_type == 'tag' }}
run: |
name="voltaserve/conversion"
version="${{ github.ref_name }}"
version="${version#v}"
IFS='.' read -r -a parts <<< "$version"
TAGS="$name:$version"
for ((i=${#parts[@]}-1; i>0; i--)); do
tag=$(IFS='.'; echo "${parts[*]:0:$i}")
TAGS+=",$name:$tag"
done
TAGS+=",$name:latest"
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: Set the tag on wokflow dispatch
if: ${{ github.ref_type != 'tag' }}
run: echo "TAGS=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: ./conversion
push: true
tags: voltaserve/conversion:${{ env.TRIMMED_TAG || 'latest' }}
tags: ${{ env.TAGS }}
platforms: linux/amd64,linux/arm64
46 changes: 34 additions & 12 deletions .github/workflows/build-idp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,38 @@ name: Build and Push voltaserve/idp

on:
workflow_dispatch:
inputs:
branch:
required: false
default: ""
type: string
description: Override code checkout branch (e.g. "feature/branch")
push:
branches:
- main
paths:
- "idp/**"
tags:
- 'v*'
pull_request:
branches:
- main
paths:
- "idp/**"

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Prepare input branch
if: ${{ github.event.inputs.branch != "" }}
run: echo "branch=refs/heads/${{ github.event.inputs.branch }}" >> $GITHUB_ENV

- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ env.branch || github.ref }}

- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64, amd64

- name: Extract tag that triggered this action
if: ${{ github.ref_type == 'tag' }}
run: |
TAG=${{ github.ref_name }}
echo "TRIMMED_TAG=${TAG#v}" >> $GITHUB_ENV
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -52,10 +53,31 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create tag list matching semver from executing tag
if: ${{ github.ref_type == 'tag' }}
run: |
name="voltaserve/idp"
version="${{ github.ref_name }}"
version="${version#v}"
IFS='.' read -r -a parts <<< "$version"
TAGS="$name:$version"
for ((i=${#parts[@]}-1; i>0; i--)); do
tag=$(IFS='.'; echo "${parts[*]:0:$i}")
TAGS+=",$name:$tag"
done
TAGS+=",$name:latest"
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: Set the tag on wokflow dispatch
if: ${{ github.ref_type != 'tag' }}
run: echo "TAGS=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: ./idp
push: true
tags: voltaserve/idp:${{ env.TRIMMED_TAG || 'latest' }}
tags: ${{ env.TAGS }}
platforms: linux/amd64,linux/arm64
41 changes: 34 additions & 7 deletions .github/workflows/build-language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ name: Build and Push voltaserve/language

on:
workflow_dispatch:
inputs:
branch:
required: false
default: ""
type: string
description: Override code checkout branch (e.g. "feature/branch")
push:
branches:
- main
Expand All @@ -29,20 +35,20 @@ jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Prepare input branch
if: ${{ github.event.inputs.branch != "" }}
run: echo "branch=refs/heads/${{ github.event.inputs.branch }}" >> $GITHUB_ENV

- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ env.branch || github.ref }}

- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64, amd64

- name: Extract tag that triggered this action
if: ${{ github.ref_type == 'tag' }}
run: |
TAG=${{ github.ref_name }}
echo "TRIMMED_TAG=${TAG#v}" >> $GITHUB_ENV
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -52,10 +58,31 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create tag list matching semver from executing tag
if: ${{ github.ref_type == 'tag' }}
run: |
name="voltaserve/language"
version="${{ github.ref_name }}"
version="${version#v}"
IFS='.' read -r -a parts <<< "$version"
TAGS="$name:$version"
for ((i=${#parts[@]}-1; i>0; i--)); do
tag=$(IFS='.'; echo "${parts[*]:0:$i}")
TAGS+=",$name:$tag"
done
TAGS+=",$name:latest"
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: Set the tag on wokflow dispatch
if: ${{ github.ref_type != 'tag' }}
run: echo "TAGS=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: ./language
push: true
tags: voltaserve/language:${{ env.TRIMMED_TAG || 'latest' }}
tags: ${{ env.TAGS }}
platforms: linux/amd64,linux/arm64
Loading

0 comments on commit 257c828

Please sign in to comment.