Skip to content

Commit 2c6059e

Browse files
authored
Merge pull request #20 from chaishiqi/patch_workflow
add workflow
2 parents 4c02a85 + 2d22048 commit 2c6059e

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/build_image.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: build_image
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags: ["v*.*.*"]
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: iotexproject/iotex-analyser-api
11+
12+
jobs:
13+
build_docker_image:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest]
19+
permissions:
20+
contents: read
21+
packages: write
22+
id-token: write
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
ref: ${{ github.event.pull_request.head.sha }}
28+
fetch-depth: 0
29+
30+
- name: Setup Docker and Colima
31+
if: startsWith(matrix.os, 'macos-latest') == true
32+
run: |
33+
brew install docker colima
34+
colima start
35+
36+
- name: Setup Docker buildx
37+
uses: docker/setup-buildx-action@v2
38+
39+
- name: Log into registry ${{ env.REGISTRY }}
40+
if: github.event_name != 'pull_request'
41+
uses: docker/login-action@v2
42+
with:
43+
registry: ${{ env.REGISTRY }}
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Extract Docker metadata
48+
id: meta-analyser
49+
uses: docker/metadata-action@v4
50+
with:
51+
images: |
52+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
54+
55+
- name: Build and push Docker image web
56+
id: build-and-push-analyser
57+
uses: docker/build-push-action@v4
58+
with:
59+
platforms: linux/amd64
60+
context: .
61+
file: ./Dockerfile
62+
push: ${{ github.event_name != 'pull_request' }}
63+
tags: ${{ steps.meta-analyser.outputs.tags }}
64+
labels: ${{ steps.meta-analyser.outputs.labels }}

0 commit comments

Comments
 (0)