Publish Docker image #15
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
name: Publish Docker image | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
module: ["none", "api", "metrics", "api,metrics"] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set env | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Tag default image | |
if: matrix.module == 'api,metrics' | |
run: echo "IMAGE_TAG_SUFFIX=" >> "$GITHUB_ENV" | |
- name: Tag api image | |
if: matrix.module == 'api' | |
run: echo "IMAGE_TAG_SUFFIX=-api" >> "$GITHUB_ENV" | |
- name: Tag metrics image | |
if: matrix.module == 'metrics' | |
run: echo "IMAGE_TAG_SUFFIX=-metrics" >> "$GITHUB_ENV" | |
- name: Tag light image | |
if: matrix.module == 'none' | |
run: echo "IMAGE_TAG_SUFFIX=-light" >> "$GITHUB_ENV" | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile.multistage | |
push: true | |
build-args: | | |
TAGS=${{ matrix.module }} | |
tags: ${{ secrets.DOCKER_USERNAME }}/stone-proxy:latest${{ env.IMAGE_TAG_SUFFIX }}, ${{ secrets.DOCKER_USERNAME }}/stone-proxy:${{ env.RELEASE_VERSION }}${{ env.IMAGE_TAG_SUFFIX }}, |