Skip to content

Build & push Docker image #54

Build & push Docker image

Build & push Docker image #54

Workflow file for this run

name: Build & push Docker image
on:
workflow_dispatch:
inputs:
version:
description: "Docker image version"
type: string
required: true
env:
SERVER_IMAGE_NAME: "grimoirelab/sortinghat"
WORKER_IMAGE_NAME: "grimoirelab/sortinghat-worker"
jobs:
build-package:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # 4.0.1
with:
node-version: ${{ matrix.node-version }}
- name: Create JS files
working-directory: ./ui
run: |
yarn install
yarn build
- name: Build package using Poetry and store result
uses: chaoss/grimoirelab-github-actions/build@main
with:
artifact-name: sortinghat-dist
artifact-path: dist
skip-checkout: yes
build-image:
runs-on: ubuntu-latest
needs: [build-package]
environment: docker-release
permissions:
contents: read
id-token: write # needed for signing the images with GitHub OIDC Token
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Download distribution artifact
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: sortinghat-dist
path: dist
- name: Install Cosign
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to DockerHub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Server Docker metadata
id: meta-server
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
with:
images: |
${{ env.SERVER_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ inputs.version }}
- name: Server Build and push
id: build-and-push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
platforms: linux/amd64,linux/arm64
context: .
file: "docker/server.dockerfile"
push: true
tags: ${{ steps.meta-server.outputs.tags }}
- name: Server Sign the images with GitHub OIDC Token
env:
TAGS: ${{ steps.meta-server.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}
- name: Worker Docker metadata
id: meta-worker
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
with:
images: |
${{ env.WORKER_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ inputs.version }}
- name: Worker Build and push
id: build-and-push-worker
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
platforms: linux/amd64,linux/arm64
context: .
file: "docker/worker.dockerfile"
push: true
tags: ${{ steps.meta-worker.outputs.tags }}
build-args: |
BASE_IMAGE_TAG=${{ inputs.version }}
- name: Worker Sign the images with GitHub OIDC Token
env:
TAGS: ${{ steps.meta-worker.outputs.tags }}
DIGEST: ${{ steps.build-and-push-worker.outputs.digest }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}