diff --git a/.github/workflows/release.yaml b/.github/workflows/deploy_gcp_bootnodes.yaml similarity index 72% rename from .github/workflows/release.yaml rename to .github/workflows/deploy_gcp_bootnodes.yaml index 59c539d1..fc61857c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/deploy_gcp_bootnodes.yaml @@ -1,18 +1,8 @@ -name: release - +name: Deploy GCP Testnet Bootnodes on: push: - branches: - - main - - test - - dev - - paths-ignore: - - 'docs/**' - - '**.md' - - '.github/workflows/build.yaml' - - '.github/workflows/gh-release.yaml' - - '.github/workflows/publish-to-docs.yaml' + tags: + - 'v*' # This will match any tag that starts with 'v' permissions: id-token: write @@ -22,49 +12,43 @@ jobs: build-and-release: runs-on: ubuntu-latest environment: - name: ${{ github.ref == 'refs/heads/main' && 'main' || github.ref == 'refs/heads/test' && 'test' || 'dev' }} + name: "test" #will expand to other envs later, currently "test" deploys to the 5 GCP bootnodes outputs: environment: ${{ steps.set-env.outputs.environment }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.21' - name: Set Version - run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - name: Build Binary run: | make build - - id: auth uses: google-github-actions/auth@v2 with: workload_identity_provider: projects/784882329213/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-oidc-provider service_account: gh-masa-oracle-${{ github.ref_name }}@masa-chain.iam.gserviceaccount.com - - name: Install Google Cloud SDK uses: google-github-actions/setup-gcloud@v2 with: version: 'latest' project_id: ${{ vars.GCP_PROJECT_ID }} - - name: Upload Binary and config for contracts npm modules to GCP run: | - BINARY_NAME=$(git rev-parse --short HEAD) - gsutil cp ./masa-node gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/masa-node - gsutil cp ./masa-node gs://${{ vars.GCP_BUCKET_NAME }}/masa-node + BINARY_NAME=${GITHUB_REF#refs/tags/} + gsutil cp ./bin/masa-node gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/masa-node + gsutil cp ./bin/masa-node gs://${{ vars.GCP_BUCKET_NAME }}/masa-node gsutil cp ./contracts/* gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/ gsutil cp ./contracts/* gs://${{ vars.GCP_BUCKET_NAME }}/ - - name: Set environment output id: set-env - run: echo "::set-output name=environment::${{ github.ref_name }}" + run: echo "environment=test" >> $GITHUB_OUTPUT deploy: needs: build-and-release @@ -77,18 +61,14 @@ jobs: with: workload_identity_provider: projects/784882329213/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-oidc-provider service_account: gh-masa-oracle-${{ github.ref_name }}@masa-chain.iam.gserviceaccount.com - - name: Update Instance Metadata run: | - ENVIRONMENT="${{ github.ref_name }}" + ENVIRONMENT="production" echo "Looking for instances with env metadata: $ENVIRONMENT" INSTANCES=$(gcloud compute instances list --filter="metadata.items.ENV=$ENVIRONMENT" --format="get(name)") - echo "Found instances: $INSTANCES" - for INSTANCE in $INSTANCES; do ZONE=$(gcloud compute instances list --filter="name=($INSTANCE)" --format="get(zone)" --limit=1) echo "Updating instance: $INSTANCE in zone: $ZONE" - gcloud compute instances add-metadata $INSTANCE --metadata masa-oracle-redeploy=latest --zone=$(echo $ZONE | tr -d '\n') + gcloud compute instances add-metadata $INSTANCE --metadata masa-oracle-redeploy=${GITHUB_REF#refs/tags/} --zone=$(echo $ZONE | tr -d '\n') done -