Skip to content

PRを作成した際にビルドする #2

PRを作成した際にビルドする

PRを作成した際にビルドする #2

name: Build and Push Multiple Docker Images
on:
pull_request:
types: [opened, synchronize, reopened, closed]
jobs:
build-and-push:
runs-on: ubuntu-latest
if: |
github.event.pull_request.merged == true ||
github.event.action == 'opened' ||
github.event.action == 'synchronize' ||
github.event.action == 'reopened'
strategy:
matrix:
include:
- context: ./
dockerfile: admin.k8s.Dockerfile
image_name: ademin_view
- context: ./
dockerfile: front.k8s.Dockerfile
image_name: user_front
- context: ./
dockerfile: api.k8s.Dockerfile
image_name: api
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ${{ matrix.context }}
file: ${{ matrix.context }}/Dockerfile
push: true
tags: ${{ matrix.image_name }}:latest