Skip to content

Workflow file for this run

name: Backend Docker Image Build
on:
push:
paths:
- "back/**"
- ".github/workflows/docker-back.yaml"
branches:
- main
workflow_dispatch:
jobs:
start-notify:
runs-on: ubuntu-latest
steps:
- name: Slack notification of build start
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_USERNAME: GitHub Actions
SLACK_COLOR: "#4381de"
SLACK_ICON: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
SLACK_TITLE: Start Openchokin backend image build
SLACK_MESSAGE: |
Start Openchokin backend image build
Run number : #${{ github.run_number }}
build-back-images:
name: Build openchokin/back Docker Image
strategy:
matrix:
arch: ["amd64", "arm64"]
include:
- arch: "amd64"
runs-on: ubuntu-latest
platform: linux/amd64
- arch: "arm64"
runs-on: macos-14
platform: linux/arm64
runs-on: ${{ matrix.runs-on }}
outputs:
imageTag: ${{ env.ImageTag }}
steps:
- name: Check out
uses: actions/checkout@v4
- name: Cache brew
if: runner.os == 'macos'
uses: actions/cache@v4
with:
path: /Users/runner/Library/Caches/Homebrew
key: ${{ runner.os }}-brew
restore-keys: |
${{ runner.os }}-brew
- name: install docker
if: runner.os == 'macos'
run: |
brew install --cask rancher
rdctl start
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: walnuts1018
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Build and push Docker images
uses: docker/[email protected]
if: github.event_name != 'release'
with:
push: true
context: .
file: ./back-prod.Dockerfile
platforms: ${{ matrix.platform }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/walnuts1018/openchokin-back:v0.0.0-${{ github.sha }}-${{ github.run_number }}-${{ matrix.arch }}
merge-images:
name: Merge docker images
runs-on: ubuntu-latest
needs: [build-back-images]
steps:
- name: Check out
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: walnuts1018
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Merge Docker images
run: |
docker buildx imagetools create --tag ghcr.io/walnuts1018/openchokin-back:latest --tag:ghcr.io/walnuts1018/openchokin-back:v0.0.0-${{ github.sha }}-${{ github.run_number }} ghcr.io/walnuts1018/openchokin-back:v0.0.0-${{ github.sha }}-${{ github.run_number }}-amd64 ghcr.io/walnuts1018/openchokin-back:v0.0.0-${{ github.sha }}-${{ github.run_number }}-arm64
SucceessNotification:
if: ${{ success() }}
name: Send Success Message
needs: [merge-images]
runs-on: ubuntu-latest
steps:
- name: Send Message to Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_USERNAME: GitHub Actions
SLACK_ICON: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
SLACK_TITLE: openchokin/back id:mage build succeeded
SLACK_MESSAGE: |
openchokin/back image build succeeded
Run number : #${{ github.run_number }}
Image tag : v0.0.0-${{ github.sha }}-${{ github.run_number }}
FailureAlert:
if: ${{ failure() }}
name: Notify failure
needs: [merge-images]
runs-on: ubuntu-latest
steps:
- name: Send Failure Alert to Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_USERNAME: GitHub Actions
SLACK_ICON: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
SLACK_TITLE: openchokin/back image build failed
SLACK_COLOR: danger
SLACK_MESSAGE: |
openchokin/back image build failed
Run number : #${{ github.run_number }}