Skip to content

Build and Deploy

Build and Deploy #1

name: Build and Deploy
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [
"timbmg/acl-search-frontend",
"timbmg/acl-search-index",
"timbmg/acl-search"
]
include:
- service: "timbmg/acl-search-frontend"
context: "frontend"
- service: "timbmg/acl-search-index"
context: "index"
- service: "timbmg/acl-search"
context: "search"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.service }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.service }}-
${{ runner.os }}-buildx-
- name: Build deployable image
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ matrix.context }}
target: build
build-args: ${{ matrix.build-args }}
push: true
tags: |
ukpsquare/${{ matrix.service }}:${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deployment
uses: distributhor/workflow-webhook@v2
env:
webhook_url: ${{ secrets.WEBHOOK_URL }}
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
data: '{"sha": "${{ github.sha }}"}'
verify_ssl: false