This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build docker container and push to Docker Hub | |
run-name: ${{ github.actor }} | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
workflow_dispatch: | |
jobs: | |
Build-Docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: jumager/caddy | |
- name: Set caddy version | |
id: caddy_version | |
run: | | |
if test ${{ github.ref_name }} == develop; then echo "version=master" >> $GITHUB_OUTPUT; else echo "version=latest" >> $GITHUB_OUTPUT; fi | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
CADDY_VERSION=${{ steps.caddy_version.outputs.version }} | |
- name: Send Webhook Notification | |
if: always() | |
env: | |
JOB_STATUS: ${{ job.status }} | |
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} | |
HOOK_OS_NAME: ${{ runner.os }} | |
WORKFLOW_NAME: ${{ github.workflow }} | |
run: | | |
git clone https://github.com/jum/github-actions-discord-webhook.git webhook | |
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL |