83 lines
2.0 KiB
YAML
83 lines
2.0 KiB
YAML
name: Build
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- '**'
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Docker Image
|
|
runs-on: almalinux-8
|
|
services:
|
|
docker:
|
|
image: docker:dind
|
|
options: --privileged
|
|
steps:
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apk add --no-cache make bash git
|
|
|
|
- name: Build Docker image
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
make build
|
|
|
|
- name: Save Docker context
|
|
if: github.event_name == 'pull_request'
|
|
run: tar -czf build-context.tar.gz .
|
|
|
|
- name: Upload build artifacts
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: build-context
|
|
path: build-context.tar.gz
|
|
|
|
deploy:
|
|
name: Deploy Docker Image
|
|
runs-on: almalinux-8
|
|
needs: build
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
services:
|
|
docker:
|
|
image: docker:dind
|
|
options: --privileged
|
|
steps:
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: build-context
|
|
|
|
- name: Extract build artifacts
|
|
run: tar -xzf build-context.tar.gz
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apk add --no-cache make bash git
|
|
|
|
- name: Log in to Docker
|
|
env:
|
|
UPLOAD_USER: ${{ secrets.UPLOAD_USER }}
|
|
UPLOAD_PASS: ${{ secrets.UPLOAD_PASS }}
|
|
run: echo "${{ secrets.UPLOAD_PASS }}" | docker login --username "${{ secrets.UPLOAD_USER }}" --password-stdin git.query.consul
|
|
|
|
- name: Push Docker image
|
|
run: |
|
|
make push
|