|
1 | 1 | name: Docker
|
2 | 2 |
|
3 | 3 | on:
|
| 4 | + schedule: |
| 5 | + - cron: '0 10 * * *' # everyday at 10am |
4 | 6 | push:
|
5 |
| - branches: [ master ] |
6 |
| - tags: ['*'] |
| 7 | + branches: |
| 8 | + - '**' |
| 9 | + tags: |
| 10 | + - 'v*.*.*' |
| 11 | + pull_request: |
7 | 12 |
|
8 | 13 | jobs:
|
9 |
| - |
10 |
| - build: |
11 |
| - name: Build |
| 14 | + docker: |
12 | 15 | runs-on: ubuntu-latest
|
13 | 16 | steps:
|
14 |
| - - name: Checkout |
| 17 | + - |
| 18 | + name: Checkout |
15 | 19 | 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 |
36 | 29 | uses: docker/setup-qemu-action@v1
|
37 |
| - - name: Set up Docker Buildx |
| 30 | + - |
| 31 | + name: Set up Docker Buildx |
38 | 32 | uses: docker/setup-buildx-action@v1
|
39 |
| - - name: Login to DockerHub |
| 33 | + - |
| 34 | + name: Login to DockerHub |
| 35 | + if: github.event_name != 'pull_request' |
40 | 36 | uses: docker/login-action@v1
|
41 | 37 | with:
|
42 | 38 | username: ${{ secrets.DOCKERHUB_USERNAME }}
|
43 | 39 | password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
44 |
| - - name: Build and push |
| 40 | + - |
| 41 | + name: Build and push |
| 42 | + id: docker_build |
45 | 43 | uses: docker/build-push-action@v2
|
46 | 44 | with:
|
47 | 45 | context: .
|
48 | 46 | file: ./Dockerfile
|
| 47 | + platforms: linux/amd64,linux/arm64 |
49 | 48 | 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