-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (41 loc) · 1.29 KB
/
docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Docker Image CI
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
REGISTRY: ${{ vars.REGISTRY }}
FULL_IMAGE: ${{ vars.REGISTRY }}/${{ github.repository }}:v${{ github.sha }}
CACHE_IMAGE: ${{ vars.REGISTRY }}/${{ github.repository }}:cache
LATEST_IMAGE: ${{ vars.REGISTRY }}/${{ github.repository }}:latest
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Ali Docker
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ env.FULL_IMAGE }}
${{ env.LATEST_IMAGE }}
platforms: linux/arm64,linux/amd64
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}
cache-to: type=registry,ref=${{ env.CACHE_IMAGE }},mode=max
env:
FULL_IMAGE: ${{ env.FULL_IMAGE }}