Docker CI #142
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: Docker CI | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "0 0 * * 0" | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
target: | |
- src: . | |
image: ghcr.io/pojntfx/weron | |
arch: "linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8,linux/386,linux/s390x" # linux/mips64le,linux/ppc64le, | |
steps: | |
- name: Maximize build space | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /opt/ghc | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up metadata | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ matrix.target.image }} | |
tags: type=semver,pattern={{version}} | |
- name: Build image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ${{ matrix.target.src }} | |
file: ${{ matrix.target.src }}/Dockerfile | |
platforms: ${{ matrix.target.arch }} | |
push: false | |
tags: ${{ matrix.target.image }}:unstable | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Push pre-release image to Docker Hub | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: docker/build-push-action@v2 | |
with: | |
context: ${{ matrix.target.src }} | |
file: ${{ matrix.target.src }}/Dockerfile | |
platforms: ${{ matrix.target.arch }} | |
push: true | |
tags: ${{ matrix.target.image }}:unstable | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Push release image to Docker Hub | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: docker/build-push-action@v2 | |
with: | |
context: ${{ matrix.target.src }} | |
file: ${{ matrix.target.src }}/Dockerfile | |
platforms: ${{ matrix.target.arch }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |