-
Notifications
You must be signed in to change notification settings - Fork 86
83 lines (70 loc) · 2.76 KB
/
Copy pathpublish.yaml
File metadata and controls
83 lines (70 loc) · 2.76 KB
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
name: Build, Publish and Deploy Docker Container
on:
push:
branches:
- develop
- main
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup GCloud - sandbox
uses: google-github-actions/setup-gcloud@v0
if: github.ref == 'refs/heads/develop'
with:
project_id: ${{ secrets.GCLOUD_FETCH_AI_SANDBOX_PROJECT }}
service_account_key: ${{ secrets.GCLOUD_FETCH_AI_SANDBOX_KEY }}
- name: Setup GCloud - production
uses: google-github-actions/setup-gcloud@v0
if: github.ref == 'refs/heads/main'
with:
project_id: ${{ secrets.GCLOUD_FETCH_AI_PROD_PROJECT }}
service_account_key: ${{ secrets.GCLOUD_FETCH_AI_PROD_KEY }}
- name: Configure Docker
run: |
gcloud auth configure-docker
- name: Set Image Tag
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# Push image to Google Container Registry
- name: Build and Push Images
run: |
chmod +x ./scripts/acn/build_upload_img.sh
if [ ${{ github.ref }} == 'refs/heads/develop' ]
then
./scripts/acn/build_upload_img.sh
fi
if [ ${{ github.ref }} == 'refs/heads/main' ]
then
./scripts/acn/build_upload_img.sh prod
fi
- name: Generate GitHub App token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.FETCHAI_DISPATCH_APP_ID }}
private-key: ${{ secrets.FETCHAI_DISPATCH_APP_KEY }}
repositories: infra-sandbox-london-b-deployment,infra-mainnet-v2-deployment
- name: Repository Dispatch
env:
IMAGE_TAG: ${{ steps.vars.outputs.sha_short }}
run: |
if [ ${{ github.ref }} == 'refs/heads/develop' ]
then
curl -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ steps.app-token.outputs.token }}" \
--request POST \
--data '{"event_type": "agents-dht-testnet", "client_payload": {"image": "gcr.io/fetch-ai-sandbox/acn_node", "tag": "'"$IMAGE_TAG"'"}}' \
https://api.github.com/repos/fetchai/infra-sandbox-london-b-deployment/dispatches
fi
if [ ${{ github.ref }} == 'refs/heads/main' ]
then
curl -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ steps.app-token.outputs.token }}" \
--request POST \
--data '{"event_type": "agents-dht", "client_payload": {"image": "gcr.io/fetch-ai-images/acn_node", "tag": "'"$IMAGE_TAG"'"}}' \
https://api.github.com/repos/fetchai/infra-mainnet-v2-deployment/dispatches
fi