77 lines
2.3 KiB
YAML
77 lines
2.3 KiB
YAML
name: Build and Push Docker Images
|
|
|
|
on:
|
|
push:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-web:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.commandware.com
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Extract metadata for web image
|
|
id: meta-web
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: git.commandware.com/demos/api7-demo/web
|
|
tags: |
|
|
type=ref,event=branch
|
|
|
|
- name: Build and push web image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./web
|
|
file: ./web/Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta-web.outputs.tags }}
|
|
labels: ${{ steps.meta-web.outputs.labels }}
|
|
cache-from: type=registry,ref=git.commandware.com/demos/api7-demo/web:buildcache
|
|
cache-to: type=registry,ref=git.commandware.com/demos/api7-demo/web:buildcache,mode=max
|
|
|
|
build-api:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.commandware.com
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Extract metadata for api image
|
|
id: meta-api
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: git.commandware.com/demos/api7-demo/api
|
|
tags: |
|
|
type=ref,event=branch
|
|
|
|
- name: Build and push api image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./api
|
|
file: ./api/Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta-api.outputs.tags }}
|
|
labels: ${{ steps.meta-api.outputs.labels }}
|
|
cache-from: type=registry,ref=git.commandware.com/demos/api7-demo/api:buildcache
|
|
cache-to: type=registry,ref=git.commandware.com/demos/api7-demo/api:buildcache,mode=max
|