mirror of https://github.com/gogs/gogs.git
ci: refurbish Docker job (#7446)
parent
167cdb09e3
commit
9ac93067f6
|
@ -14,28 +14,24 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
buildx:
|
buildx:
|
||||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
actions: write
|
actions: write
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel previous runs
|
|
||||||
uses: styfle/cancel-workflow-action@0.9.1
|
|
||||||
with:
|
|
||||||
all_but_latest: true
|
|
||||||
access_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
|
||||||
config-inline: |
|
|
||||||
[worker.oci]
|
|
||||||
max-parallelism = 2
|
|
||||||
- name: Inspect builder
|
- name: Inspect builder
|
||||||
run: |
|
run: |
|
||||||
echo "Name: ${{ steps.buildx.outputs.name }}"
|
echo "Name: ${{ steps.buildx.outputs.name }}"
|
||||||
|
@ -44,18 +40,18 @@ jobs:
|
||||||
echo "Flags: ${{ steps.buildx.outputs.flags }}"
|
echo "Flags: ${{ steps.buildx.outputs.flags }}"
|
||||||
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
|
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Login to GitHub Container registry
|
- name: Login to GitHub Container registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push images
|
- name: Build and push images
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
|
@ -87,10 +83,10 @@ jobs:
|
||||||
contents: read
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
config-inline: |
|
config-inline: |
|
||||||
[worker.oci]
|
[worker.oci]
|
||||||
|
@ -103,15 +99,16 @@ jobs:
|
||||||
echo "Flags: ${{ steps.buildx.outputs.flags }}"
|
echo "Flags: ${{ steps.buildx.outputs.flags }}"
|
||||||
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
|
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
|
||||||
- name: Compute short commit SHA
|
- name: Compute short commit SHA
|
||||||
uses: benjlevesque/short-sha@v1.2
|
id: short-sha
|
||||||
|
uses: benjlevesque/short-sha@v2.1
|
||||||
- name: Build and push images
|
- name: Build and push images
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
ttl.sh/gogs/gogs-${{ env.SHA }}:1d
|
ttl.sh/gogs/gogs-${{ steps.short-sha.outputs.sha }}:1d
|
||||||
|
|
||||||
# Updates to the following section needs to be synced to all release branches within their lifecycles.
|
# Updates to the following section needs to be synced to all release branches within their lifecycles.
|
||||||
buildx-release:
|
buildx-release:
|
||||||
|
@ -125,16 +122,14 @@ jobs:
|
||||||
- name: Compute image tag name
|
- name: Compute image tag name
|
||||||
run: echo "IMAGE_TAG=$(echo $GITHUB_REF_NAME | cut -c 2-)" >> $GITHUB_ENV
|
run: echo "IMAGE_TAG=$(echo $GITHUB_REF_NAME | cut -c 2-)" >> $GITHUB_ENV
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
|
||||||
config-inline: |
|
|
||||||
[worker.oci]
|
|
||||||
max-parallelism = 2
|
|
||||||
- name: Inspect builder
|
- name: Inspect builder
|
||||||
run: |
|
run: |
|
||||||
echo "Name: ${{ steps.buildx.outputs.name }}"
|
echo "Name: ${{ steps.buildx.outputs.name }}"
|
||||||
|
@ -143,18 +138,18 @@ jobs:
|
||||||
echo "Flags: ${{ steps.buildx.outputs.flags }}"
|
echo "Flags: ${{ steps.buildx.outputs.flags }}"
|
||||||
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
|
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Login to GitHub Container registry
|
- name: Login to GitHub Container registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push images
|
- name: Build and push images
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
|
|
Loading…
Reference in New Issue