wings/.github/workflows/docker.yaml

79 lines
2.6 KiB
YAML
Raw Permalink Normal View History

2022-11-06 20:55:49 +00:00
name: Docker
2020-11-15 04:42:12 +00:00
on:
push:
branches:
- develop
2022-12-05 00:24:33 +00:00
release:
types:
- published
2022-11-06 20:55:49 +00:00
2020-11-15 04:42:12 +00:00
jobs:
2022-11-06 20:55:49 +00:00
build-and-push:
name: Build and Push
2023-07-15 20:40:45 +00:00
runs-on: ubuntu-22.04
2020-12-15 22:59:06 +00:00
# Always run against a tag, even if the commit into the tag has [docker skip] within the commit message.
2020-11-15 04:42:12 +00:00
if: "!contains(github.ref, 'develop') || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))"
steps:
2022-12-05 00:24:33 +00:00
- name: Code checkout
uses: actions/checkout@v4
2022-11-06 20:55:49 +00:00
2022-12-05 00:39:55 +00:00
- name: Docker metadata
2020-12-15 23:08:06 +00:00
id: docker_meta
uses: docker/metadata-action@v5
2020-12-15 23:08:06 +00:00
with:
images: ghcr.io/pterodactyl/wings
2022-12-05 01:37:53 +00:00
flavor: |
latest=false
2022-12-05 00:24:33 +00:00
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.action == 'published' && github.event.release.prerelease == false }}
type=ref,event=tag
type=ref,event=branch
2022-11-06 20:55:49 +00:00
2022-12-05 00:24:33 +00:00
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
2022-11-06 20:55:49 +00:00
2022-12-05 00:39:55 +00:00
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
2022-11-06 20:55:49 +00:00
2020-12-15 22:59:06 +00:00
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
2020-11-15 04:42:12 +00:00
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
2022-11-06 20:55:49 +00:00
2020-12-15 23:24:15 +00:00
- name: Get Build Information
id: build_info
run: |
echo "version_tag=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
2022-11-06 20:55:49 +00:00
2022-12-05 00:24:33 +00:00
- name: Build and Push (tag)
uses: docker/build-push-action@v5
2022-12-05 00:24:33 +00:00
if: "github.event_name == 'release' && github.event.action == 'published'"
2020-11-15 04:42:12 +00:00
with:
2022-11-06 20:55:49 +00:00
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
2020-11-15 04:42:12 +00:00
build-args: |
2020-12-15 23:24:15 +00:00
VERSION=${{ steps.build_info.outputs.version_tag }}
2020-11-15 04:42:12 +00:00
labels: ${{ steps.docker_meta.outputs.labels }}
2020-12-15 22:59:06 +00:00
tags: ${{ steps.docker_meta.outputs.tags }}
2022-11-06 20:55:49 +00:00
2022-12-05 00:24:33 +00:00
- name: Build and Push (develop)
uses: docker/build-push-action@v5
2022-12-05 00:24:33 +00:00
if: "github.event_name == 'push' && contains(github.ref, 'develop')"
2020-11-15 04:42:12 +00:00
with:
2022-11-06 20:55:49 +00:00
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
2020-11-15 04:42:12 +00:00
build-args: |
2020-12-15 23:24:15 +00:00
VERSION=dev-${{ steps.build_info.outputs.short_sha }}
2020-11-15 04:42:12 +00:00
labels: ${{ steps.docker_meta.outputs.labels }}
2020-12-15 22:59:06 +00:00
tags: ${{ steps.docker_meta.outputs.tags }}
2022-11-06 20:55:49 +00:00
cache-from: type=gha
cache-to: type=gha,mode=max