Skip to content

Commit

Permalink
Merge pull request #84 from weaveVM/fix/fix-ci-workflow
Browse files Browse the repository at this point in the history
fix: fix ci workflow
  • Loading branch information
allnil authored Oct 15, 2024
2 parents 468e025 + cb180f3 commit 42b2d5e
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions .github/workflows/gcp-docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Google Artifact Registry

on:
push:
branches:
Expand All @@ -17,10 +18,12 @@ jobs:
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
Expand All @@ -29,19 +32,23 @@ jobs:
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
Expand All @@ -61,30 +68,44 @@ jobs:
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "Docker tag: ${tag}"
- name: Build
# 7. Build Docker Image (Load Locally Only)
- name: Build Docker Image
uses: docker/build-push-action@v6
with:
load: true
tags: wevm:local,us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.get-tag.outputs.short_ref }},us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.tag.outputs.tag }}
push: false # Do not push in this step
load: true # Load the image into Docker cache
tags: |
wevm:local
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.get-tag.outputs.short_ref }}
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.tag.outputs.tag }}
cache-from: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.tag.outputs.tag }}
cache-to: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ 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
docker compose up -d
npm i
npm install
SIGNER_KEY=${{ secrets.TEST_SIGNER_KEY }} node test.js
docker compose down
cd .. && sudo rm -rf .testnet
- name: Build
# 9. Push Verified Docker Images to Artifact Registry
- name: Push to Artifact Registry
uses: docker/build-push-action@v6
with:
push: true
tags: wevm:local,us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.get-tag.outputs.short_ref }},us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.tag.outputs.tag }}
push: true # Enable pushing
tags: |
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.get-tag.outputs.short_ref }}
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.tag.outputs.tag }}
cache-from: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ steps.tag.outputs.tag }}
cache-to: type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wevm:${{ 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 wevm:local || true

0 comments on commit 42b2d5e

Please sign in to comment.