hexabot/.github/workflows/merge.yml

79 lines
2.2 KiB
YAML
Raw Normal View History

2024-09-18 11:25:56 +00:00
name: Build and Push Docker Image On Merge
2024-09-19 10:25:09 +00:00
2024-09-18 11:25:56 +00:00
on:
push:
branches: ['main']
workflow_dispatch:
jobs:
paths-filter:
runs-on: ubuntu-latest
outputs:
frontend: ${{ steps.filter.outputs.frontend }}
api: ${{ steps.filter.outputs.api }}
widget: ${{ steps.filter.outputs.widget }}
steps:
- uses: actions/checkout@v4
- name: Filter paths
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
frontend:
- 'frontend/**'
2024-09-19 10:25:09 +00:00
api:
2024-09-18 11:25:56 +00:00
- 'api/**'
widget:
- 'widget/**'
2024-09-19 10:25:09 +00:00
build-and-push:
2024-09-18 11:25:56 +00:00
runs-on: ubuntu-latest
2024-09-19 10:25:09 +00:00
needs:
- paths-filter
2024-09-18 11:25:56 +00:00
steps:
2024-09-19 10:25:09 +00:00
- name: Check out repository code
2024-09-18 11:25:56 +00:00
uses: actions/checkout@v4
2024-09-19 10:25:09 +00:00
2024-09-18 11:25:56 +00:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
2024-09-19 10:25:09 +00:00
2024-09-18 11:25:56 +00:00
- name: Login to Docker Hub
2024-09-19 10:25:09 +00:00
id: docker_login
uses: docker/login-action@v2
2024-09-18 11:25:56 +00:00
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2024-09-19 10:25:09 +00:00
- name: Build and push frontend Docker image
if: ${{ needs.paths-filter.outputs.frontend == 'true' }}
2024-09-18 11:25:56 +00:00
uses: docker/build-push-action@v6
with:
2024-09-19 10:25:09 +00:00
context: ./
file: ./frontend/Dockerfile
2024-09-18 11:25:56 +00:00
platforms: linux/amd64,linux/arm64
push: true
2024-09-19 10:25:09 +00:00
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-frontend:latest
2024-09-18 11:25:56 +00:00
2024-09-19 10:25:09 +00:00
- name: Build and push API Docker image
if: ${{ needs.paths-filter.outputs.api == 'true' }}
2024-09-18 11:25:56 +00:00
uses: docker/build-push-action@v6
with:
2024-09-19 10:25:09 +00:00
context: ./
file: ./api/Dockerfile
2024-09-18 11:25:56 +00:00
platforms: linux/amd64,linux/arm64
push: true
2024-09-19 10:25:09 +00:00
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-api:latest
2024-09-18 11:25:56 +00:00
2024-09-19 10:25:09 +00:00
- name: Build and push widget Docker image
if: ${{ needs.paths-filter.outputs.widget == 'true' }}
2024-09-18 11:25:56 +00:00
uses: docker/build-push-action@v6
with:
2024-09-19 10:25:09 +00:00
context: ./
file: ./widget/Dockerfile
2024-09-18 11:25:56 +00:00
platforms: linux/amd64,linux/arm64
push: true
2024-09-19 10:25:09 +00:00
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hexabot-widget:latest