mirror of https://github.com/gogs/gogs.git
74 lines
2.4 KiB
YAML
74 lines
2.4 KiB
YAML
name: Docker
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
paths:
|
|
- 'Dockerfile'
|
|
- 'docker/**'
|
|
- '.github/workflows/docker.yml'
|
|
|
|
jobs:
|
|
buildx:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Canel previous runs on main
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
uses: styfle/cancel-workflow-action@0.9.1
|
|
with:
|
|
all_but_latest: true
|
|
access_token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
- name: Set up QEMU
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
uses: docker/setup-qemu-action@v1
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
with:
|
|
config-inline: |
|
|
[worker.oci]
|
|
max-parallelism = 2
|
|
- name: Inspect builder
|
|
run: |
|
|
echo "Name: ${{ steps.buildx.outputs.name }}"
|
|
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
|
|
echo "Status: ${{ steps.buildx.outputs.status }}"
|
|
echo "Flags: ${{ steps.buildx.outputs.flags }}"
|
|
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Login to GitHub Container registry
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Get short commit SHA
|
|
uses: benjlevesque/short-sha@v1.2
|
|
- name: Build and push images on pull requests
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: |
|
|
gogs/gogs:commit-${{ env.SHA }}
|
|
- name: Build and push images on main
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
push: true
|
|
tags: |
|
|
gogs/gogs:latest
|
|
ghcr.io/gogs/gogs:latest
|