Skip to content

Commit

Permalink
ci: add GH Actions release workflow
Browse files Browse the repository at this point in the history
Add a workflow that is only triggered when a GH Release is created.

Signed-off-by: Leonardo Graboski Veiga <[email protected]>
  • Loading branch information
leograba committed Aug 31, 2024
1 parent 9766e83 commit 1b05124
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 80 deletions.
48 changes: 48 additions & 0 deletions .github/actions/docker-build-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker Build and Push
description: Reusable Docker build and push logic

inputs:
username:
description: 'Docker Hub registry username'
required: true
password:
description: 'Docker Hub password'
required: true
context:
description: 'The Docker build context'
required: true
imgarch:
description: 'Architecture of the container image'
required: true
tagname:
description: 'Docker tag name before the :'
required: true
tagversion:
description: 'Docker tag version after the :'
required: true

runs:
using: "composite"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
context: ${{ inputs.context }}
platforms: linux/${{ inputs.imgarch }}
build-args: |
IMAGE_ARCH=${{ inputs.imgarch }}
tags: |
${{ inputs.username }}/${{ inputs.tagname }}:${{ inputs.tagversion }}
44 changes: 28 additions & 16 deletions .github/workflows/build-Browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: Browser
env:
wdir: browser
arch: arm
imgname: torizon-os-build-status-browser

on:
push:
paths:
- 'browser/**'
release:
types: [created]

jobs:
build:
Expand All @@ -20,29 +23,38 @@ jobs:
- name: Git checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Build and push release candidate
uses: ./.github/actions/docker-build-push
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: rc

release:
needs: [build]
if: github.event_name == 'release'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.wdir }}

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Get container tag
run: |
echo "CONTAINER_TAG=$(jq -r '.docker_tag' .vscode/settings.json)" >> $GITHUB_ENV
- name: Build and push release candidate
uses: docker/build-push-action@v5
- name: Build and push tagged release
uses: ./.github/actions/docker-build-push
with:
push: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
platforms: linux/${{ env.arch }}
build-args: |
IMAGE_ARCH=${{ env.arch }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/torizon-os-build-status-browser:rc
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: ${{ env.CONTAINER_TAG }}
44 changes: 28 additions & 16 deletions .github/workflows/build-DataAcquisition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: Data Acquisition App
env:
wdir: dataAcquisition
arch: arm64
imgname: torizon-os-build-status-data-acquisition

on:
push:
paths:
- 'dataAcquisition/**'
release:
types: [created]

jobs:
build:
Expand All @@ -20,29 +23,38 @@ jobs:
- name: Git checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Build and push release candidate
uses: ./.github/actions/docker-build-push
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: rc

release:
needs: [build]
if: github.event_name == 'release'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.wdir }}

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Get container tag
run: |
echo "CONTAINER_TAG=$(jq -r '.docker_tag' .vscode/settings.json)" >> $GITHUB_ENV
- name: Build and push release candidate
uses: docker/build-push-action@v5
- name: Build and push tagged release
uses: ./.github/actions/docker-build-push
with:
push: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
platforms: linux/${{ env.arch }}
build-args: |
IMAGE_ARCH=${{ env.arch }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/torizon-os-build-status-data-acquisition:rc
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: ${{ env.CONTAINER_TAG }}
44 changes: 28 additions & 16 deletions .github/workflows/build-Grafana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: Grafana
env:
wdir: grafana
arch: arm64
imgname: torizon-os-build-status-grafana

on:
push:
paths:
- 'grafana/**'
release:
types: [created]

jobs:
build:
Expand All @@ -20,29 +23,38 @@ jobs:
- name: Git checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Build and push release candidate
uses: ./.github/actions/docker-build-push
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: rc

release:
needs: [build]
if: github.event_name == 'release'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.wdir }}

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Get container tag
run: |
echo "CONTAINER_TAG=$(jq -r '.docker_tag' .vscode/settings.json)" >> $GITHUB_ENV
- name: Build and push release candidate
uses: docker/build-push-action@v5
- name: Build and push tagged release
uses: ./.github/actions/docker-build-push
with:
push: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
platforms: linux/${{ env.arch }}
build-args: |
IMAGE_ARCH=${{ env.arch }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/torizon-os-build-status-grafana:rc
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: ${{ env.CONTAINER_TAG }}
44 changes: 28 additions & 16 deletions .github/workflows/build-InfluxDB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: InfluxDB
env:
wdir: influxdb
arch: arm64
imgname: torizon-os-build-status-influxdb

on:
push:
paths:
- 'influxdb/**'
release:
types: [created]

jobs:
build:
Expand All @@ -20,29 +23,38 @@ jobs:
- name: Git checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Build and push release candidate
uses: ./.github/actions/docker-build-push
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: rc

release:
needs: [build]
if: github.event_name == 'release'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.wdir }}

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Get container tag
run: |
echo "CONTAINER_TAG=$(jq -r '.docker_tag' .vscode/settings.json)" >> $GITHUB_ENV
- name: Build and push release candidate
uses: docker/build-push-action@v5
- name: Build and push tagged release
uses: ./.github/actions/docker-build-push
with:
push: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
platforms: linux/${{ env.arch }}
build-args: |
IMAGE_ARCH=${{ env.arch }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/torizon-os-build-status-influxdb:rc
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: ${{ env.CONTAINER_TAG }}
44 changes: 28 additions & 16 deletions .github/workflows/build-Weston.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: Weston
env:
wdir: weston
arch: arm
imgname: torizon-os-build-status-weston

on:
push:
paths:
- 'weston/**'
release:
types: [created]

jobs:
build:
Expand All @@ -20,29 +23,38 @@ jobs:
- name: Git checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Build and push release candidate
uses: ./.github/actions/docker-build-push
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: rc

release:
needs: [build]
if: github.event_name == 'release'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.wdir }}

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Get container tag
run: |
echo "CONTAINER_TAG=$(jq -r '.docker_tag' .vscode/settings.json)" >> $GITHUB_ENV
- name: Build and push release candidate
uses: docker/build-push-action@v5
- name: Build and push tagged release
uses: ./.github/actions/docker-build-push
with:
push: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
context: ${{ env.wdir }}
platforms: linux/${{ env.arch }}
build-args: |
IMAGE_ARCH=${{ env.arch }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/torizon-os-build-status-weston:rc
imgarch: ${{ env.arch }}
tagname: ${{ env.imgname }}
tagversion: ${{ env.CONTAINER_TAG }}
Loading

0 comments on commit 1b05124

Please sign in to comment.