58 lines
1.6 KiB
YAML
58 lines
1.6 KiB
YAML
name: Docker Build and Push with Version
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
env:
|
|
DOCKER_REGISTRY: r.regnault.dev
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
PORTAINER_API_WEBHOOK: ${{ secrets.PORTAINER_API_WEBHOOK }}
|
|
|
|
jobs:
|
|
build_and_push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.DOCKER_REGISTRY }}
|
|
username: ${{ env.DOCKER_USERNAME }}
|
|
password: ${{ env.DOCKER_PASSWORD }}
|
|
|
|
- name: Install cargo-semver
|
|
uses: actions-rs/install@v0.1.2
|
|
with:
|
|
crate: cargo-get
|
|
version: latest
|
|
|
|
- name: Semver
|
|
run:
|
|
echo "VERSION=$(cargo get package.version --pretty)" >> $GITHUB_ENV
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ env.DOCKER_REGISTRY }}/drunk-venti-rust:latest
|
|
${{ env.DOCKER_REGISTRY }}/drunk-venti-rust:${{ env.VERSION }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Deploy to production
|
|
uses: fjogeleit/http-request-action@v1.14.1
|
|
with:
|
|
url: ${{ format('{0}?BOT_TAG={1}',env.PORTAINER_API_WEBHOOK, env.VERSION) }}
|
|
method: 'POST'
|
|
preventFailureOnNoResponse: true
|