forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 2
127 lines (112 loc) · 4.93 KB
/
gcp-docker.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Google Artifact Registry
on:
push:
branches:
- main
- dev
- dockercomposeaction
tags:
- "*"
jobs:
docker-release:
name: Tagged Docker release to Google Artifact Registry
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
# 1. Checkout the Repository
- id: checkout
name: Checkout
uses: actions/checkout@v4
# 2. Authenticate with Google Cloud
- id: auth
name: Authenticate with Google Cloud
uses: google-github-actions/auth@v2
with:
token_format: access_token
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
access_token_lifetime: 1800s
# 3. Configure Docker to Use Google Artifact Registry
- name: Configure container registry
run: gcloud auth configure-docker us-east1-docker.pkg.dev
# 4. Set Up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 5. Login to Artifact Registry
- name: Login to Artifact Registry
uses: docker/login-action@v3
with:
registry: us-east1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
# 6. Determine Docker Tag Based on Git Reference
- name: Get tag
id: get-tag
run: echo "short_ref=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Set Docker Tag
id: tag
run: |
if [[ "${GITHUB_REF}" == refs/heads/main ]]; then
tag="latest"
elif [[ "${GITHUB_REF}" == refs/heads/dev ]]; then
tag="nightly"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
tag=${GITHUB_REF#refs/tags/}
else
tag=${GITHUB_REF#refs/heads/}
fi
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "Docker tag: ${tag}"
# 7. Build Docker Image (Load Locally Only)
- name: Build Docker Image
uses: docker/build-push-action@v6
with:
push: false # Do not push in this step
load: true # Load the image into Docker cache
tags: |
wvm:local
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.get-tag.outputs.short_ref }}
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.tag.outputs.tag }}
cache-from: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.tag.outputs.tag }}
cache-to: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.tag.outputs.tag }},mode=max
# 8. Test Docker Image Using Local Tag
- name: Test Docker
run: |-
mkdir -m 777 .testnet
cd .testnet
git clone https://github.com/weaveVM/wvm-docker-testnet.git .
echo "${{ secrets.GCP_CREDENTIALS_JSON }}" > ./execution/key.json
./clean.sh
docker compose up -d || {
echo "Docker Compose failed. Collecting logs...";
docker ps -a; # Show status of all containers
docker compose logs > compose_logs.txt;
docker logs testnet-reth-genesis-1 > reth-genesis.log 2>&1 || echo "No logs for testnet-reth-genesis-1";
docker logs testnet-create-beacon-chain-genesis-1 > beacon-genesis.log 2>&1 || echo "No logs for testnet-create-beacon-chain-genesis-1";
echo "Logs for reth-genesis:";
cat reth-genesis.log;
echo "Logs for beacon-genesis:";
cat beacon-genesis.log;
echo "All Docker Compose logs:";
cat compose_logs.txt;
exit 1;
}
npm install
SIGNER_KEY=${{ secrets.TEST_SIGNER_KEY }} node test.js
docker compose down
cd .. && sudo rm -rf .testnet
# 9. Push Verified Docker Images to Artifact Registry
- name: Push to Artifact Registry
uses: docker/build-push-action@v6
with:
push: true # Enable pushing
tags: |
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.get-tag.outputs.short_ref }}
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.tag.outputs.tag }}
cache-from: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.tag.outputs.tag }}
cache-to: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:${{ steps.tag.outputs.tag }},mode=max
# 10. Clean Up Local Docker Tags (Optional)
- name: Remove Local Tag
if: always() # Run regardless of previous step outcomes
run: docker rmi wvm:local || true