-
Notifications
You must be signed in to change notification settings - Fork 5
97 lines (79 loc) · 2.33 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: CI
on:
push:
branches:
- hiep/add-github-actions
tags:
- '*'
jobs:
build_lint_test:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.3
- name: Print Go environment
run: go env
- name: Cache Go modules
id: go-cache
uses: actions/cache@v4
with:
path: |
~/.go/pkg/mod
~/.cache/go-build
key: go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: |
go-mod-
- name: Install Dependencies
run: sudo apt-get install libzmq3-dev
- name: Build staking-indexer
run: make build
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2
./bin/golangci-lint run --timeout 5m0s
- name: Run tests
run: make test
- name: Run integration tests
run: make test-e2e
build_docker:
runs-on: ubuntu-22.04
needs: build_lint_test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
tags: staking-indexer:${{ github.sha }}
outputs: type=docker,dest=/tmp/staking-indexer.tar
- name: Upload Docker image to workspace
uses: actions/upload-artifact@v4
with:
name: staking-indexer
path: /tmp/staking-indexer.tar
push_docker:
runs-on: ubuntu-22.04
needs: build_docker
steps:
- name: Download Docker image from workspace
uses: actions/download-artifact@v4
with:
name: staking-indexer
path: /tmp/
- name: Load Docker image
run: docker load -i /tmp/staking-indexer.tar
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
run: |
docker tag staking-indexer:${{ github.sha }} ${{ secrets.DOCKERHUB_REGISTRY }}/staking-indexer:${{ github.sha }}
docker push ${{ secrets.DOCKERHUB_REGISTRY }}/staking-indexer:${{ github.sha }}