aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2021-12-15 16:20:39 +0800
committerGitHub <noreply@github.com>2021-12-15 16:20:39 +0800
commit8ee734b1df40e291e1199a3a1b1c2ce4a09ed57c (patch)
tree0023ec0270eb0c340ab763bb8949d1796612e86e
parent7867163bfd6ab0c07a17e5be769fc2a6900a0fb0 (diff)
ci: build and push Docker images on `main` branch (#6659)
-rw-r--r--.github/workflows/docker.yml63
-rw-r--r--.github/workflows/go.yml3
-rw-r--r--Dockerfile4
3 files changed, 67 insertions, 3 deletions
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 00000000..19dc08aa
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,63 @@
+name: Docker
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ paths:
+ - 'Dockerfile'
+ - 'docker/**'
+ - '.github/workflows/docker.yml'
+
+jobs:
+ buildx:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Set up QEMU
+ id: qemu
+ 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: Build images on pull requests
+ if: ${{ github.event_name == 'pull_request' }}
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64,linux/arm/v7
+ - name: Login to Docker Hub
+ if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
+ 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: Build and push images on commits to 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
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 30c9901a..6a3509ad 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -23,7 +23,8 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - name: Checkout code
+ uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
diff --git a/Dockerfile b/Dockerfile
index faf651ca..2af8daec 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM golang:alpine3.11 AS binarybuilder
+FROM golang:alpine3.12 AS binarybuilder
RUN apk --no-cache --no-progress add --virtual \
build-deps \
build-base \
@@ -9,7 +9,7 @@ WORKDIR /gogs.io/gogs
COPY . .
RUN make build TAGS="cert pam"
-FROM alpine:3.11
+FROM alpine:3.12
RUN if [ `uname -m` == "aarch64" ] ; then \
export arch="arm64" ; \
elif [ `uname -m` == "armv7l" ] ; then \