Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and push #114

Merged
merged 15 commits into from
Nov 30, 2021
73 changes: 57 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,68 @@
name: Test
name: Build and Push Image

on: [push]
on: push

jobs:
build:
build-and-push:
strategy:
fail-fast: false
matrix:
image: [nereid, redis, celeryworker]
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ secrets.ACR_SERVER }}/nereid/${{ matrix.image }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo "tags: $TAGS"
echo ::set-output name=tags::${TAGS}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"

- name: Login to Azure
uses: azure/docker-login@v1
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
login-server: ${{ secrets.ACR_SERVER }}
registry: ${{ secrets.ACR_SERVER }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: build stack
env:
ACR_SERVER: ${{ secrets.ACR_SERVER }}
run: |
docker --version
bash ./scripts/build_deploy.sh
docker-compose -f docker-stack.yml build
docker-compose -f docker-stack.yml push

- name: Build and Push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./nereid
file: ./nereid/Dockerfile.multi
target: ${{ matrix.image }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}