Skip to content
This repository was archived by the owner on Mar 24, 2021. It is now read-only.

Commit ac808be

Browse files
committedNov 10, 2020
Update github auto build docker image
1 parent 4ad9e74 commit ac808be

File tree

1 file changed

+30
-35
lines changed

1 file changed

+30
-35
lines changed
 

‎.github/workflows/docker.yml

+30-35
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,50 @@
11
name: Docker
22

33
on:
4+
schedule:
5+
- cron: '0 10 * * *' # everyday at 10am
46
push:
5-
branches: [ master ]
6-
tags: ['*']
7+
branches:
8+
- '**'
9+
tags:
10+
- 'v*.*.*'
11+
pull_request:
712

813
jobs:
9-
10-
build:
11-
name: Build
14+
docker:
1215
runs-on: ubuntu-latest
1316
steps:
14-
- name: Checkout
17+
-
18+
name: Checkout
1519
uses: actions/checkout@v2
16-
- name: Prepare
17-
id: prep
18-
run: |
19-
DOCKER_IMAGE=openpitrix/release-app
20-
VERSION=edge
21-
if [[ $GITHUB_REF == refs/tags/* ]]; then
22-
VERSION=${GITHUB_REF#refs/tags/}
23-
elif [[ $GITHUB_REF == refs/heads/* ]]; then
24-
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
25-
elif [[ $GITHUB_REF == refs/pull/* ]]; then
26-
VERSION=pr-${{ github.event.number }}
27-
fi
28-
TAGS="${DOCKER_IMAGE}:${VERSION}"
29-
if [ "${{ github.event_name }}" = "push" ]; then
30-
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
31-
fi
32-
echo ::set-output name=version::${VERSION}
33-
echo ::set-output name=tags::${TAGS}
34-
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
35-
- name: Set up QEMU
20+
-
21+
name: Docker meta
22+
id: docker_meta
23+
uses: crazy-max/ghaction-docker-meta@v1
24+
with:
25+
images: openpitrix/release-app
26+
tag-sha: true
27+
-
28+
name: Set up QEMU
3629
uses: docker/setup-qemu-action@v1
37-
- name: Set up Docker Buildx
30+
-
31+
name: Set up Docker Buildx
3832
uses: docker/setup-buildx-action@v1
39-
- name: Login to DockerHub
33+
-
34+
name: Login to DockerHub
35+
if: github.event_name != 'pull_request'
4036
uses: docker/login-action@v1
4137
with:
4238
username: ${{ secrets.DOCKERHUB_USERNAME }}
4339
password: ${{ secrets.DOCKERHUB_PASSWORD }}
44-
- name: Build and push
40+
-
41+
name: Build and push
42+
id: docker_build
4543
uses: docker/build-push-action@v2
4644
with:
4745
context: .
4846
file: ./Dockerfile
47+
platforms: linux/amd64,linux/arm64
4948
push: ${{ github.event_name != 'pull_request' }}
50-
tags: ${{ steps.prep.outputs.tags }}
51-
labels: |
52-
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
53-
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
54-
org.opencontainers.image.revision=${{ github.sha }}
55-
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
49+
tags: ${{ steps.docker_meta.outputs.tags }}
50+
labels: ${{ steps.docker_meta.outputs.labels }}

0 commit comments

Comments
 (0)