-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 2.57 KB
/
build-and-deploy.yaml
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
name: Build and Push Docker Images
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: "Select environment"
required: true
options:
- finney
- testnet
env:
REGISTRY: ghcr.io
ORGANIZATION: ${{ github.repository_owner }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker images
run: |
for dir in ./scraper_service/shovel_*/; do
if [ -f "${dir}Dockerfile" ]; then
dir_name=$(basename "$dir")
echo "Building and pushing image for $dir_name"
docker buildx build \
-f ${dir}/Dockerfile \
--push \
--tag ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${dir_name}:${{ github.sha }} \
./scraper_service
fi
done
- name: Update YAML in other repository
env:
PAT: ${{ secrets.PAT_FOR_PRIVATE_REPO }}
run: |
git clone https://${PAT}@github.com/opentensor/ops-setup.git
for dir in ./scraper_service/shovel_*/; do
if [ -f "${dir}Dockerfile" ]; then
dir_name=$(basename "$dir")
if [ "${{ github.event.inputs.environment }}" == "finney" ]; then
yaml_file="ops-setup/clusters/data-warehouse-finney/indexers/${dir_name}.yaml"
elif [ "${{ github.event.inputs.environment }}" == "testnet" ]; then
yaml_file="ops-setup/clusters/data-warehouse-testnet/indexers/${dir_name}.yaml"
fi
if [ -f "$yaml_file" ]; then
sed -i 's|image: .*|image: ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/'${dir_name}':${{ github.sha }}|' "$yaml_file"
else
echo "Warning: $yaml_file not found"
fi
fi
done
cd ops-setup
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Update indexers on ${{github.events.inputs.environment}} tags to ${{ github.sha }}"
git push