Skip to content

Build and Publish Docker Image #22

Build and Publish Docker Image

Build and Publish Docker Image #22

Workflow file for this run

name: Build and Publish Docker Image
on:
workflow_run:
workflows:
- Release
types:
- completed
jobs:
build-and-publish:
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'master'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install dependencies
run: npm install
- name: Get version from Release workflow
id: get_version
run: |
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0") # Assuming tags follow the release version
echo "Version: $VERSION"
echo "::set-output name=version::$VERSION"
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU for multi-platform support
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/statstream:latest
${{ secrets.DOCKER_USERNAME }}/statstream:${{ github.sha }}
${{ secrets.DOCKER_USERNAME }}/statstream:${{ steps.get_version.outputs.version }}
platforms: linux/amd64,linux/arm64