diff --git a/.github/workflows/chore-clean-dev.yml b/.github/workflows/chore-clean-dev.yml index 95d87db..3c792cb 100644 --- a/.github/workflows/chore-clean-dev.yml +++ b/.github/workflows/chore-clean-dev.yml @@ -26,7 +26,7 @@ jobs: service_account: '${{ vars.GCP_DEPLOYMENTS_SA }}' - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v1.1.1 + uses: google-github-actions/setup-gcloud@v2.1.0 - name: Removing CR service run: | diff --git a/.github/workflows/gcloud.yml b/.github/workflows/gcloud.yml new file mode 100644 index 0000000..b4bdcbf --- /dev/null +++ b/.github/workflows/gcloud.yml @@ -0,0 +1,58 @@ +name: gcloud + +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + branches: + - master + +env: + PROJECT_ID: ecosystem-infrastructure + GCLOUD_ZONE: us-central1-a + +jobs: + build-deploy: + name: Google Cloud Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set project and image names + run: | + BRANCH_NAME=$GITHUB_REPOSITORY/$(expr $GITHUB_REF : '.*/\(.*\)') && \ + BRANCH_NAME=${BRANCH_NAME,,} && \ + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV && \ + echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV + + # Setup gcloud CLI + - name: Authenticate to Google Cloud + id: auth + uses: google-github-actions/auth@v2.1.2 + with: + project_id: ${{ env.PROJECT_ID }} + credentials_json: '${{ secrets.GCLOUD_SA_KEY }}' + + - uses: google-github-actions/setup-gcloud@v2.1.0 + + # Build and push image to Google Container Registry + - name: Build + # Tagging w/ the commit SHA blocks the :latest tag on GCR + run: | + gcloud builds submit ./docker --dir . \ + --tag "gcr.io/$PROJECT_ID/$BRANCH_NAME:$SHORT_SHA" + # Deploy image to Compute Engine + - name: Deploy + run: | + gcloud compute instances create-with-container "zfnd-seeder-$SHORT_SHA" \ + --zone "$GCLOUD_ZONE" \ + --service-account instance-service-account@ecosystem-infrastructure.iam.gserviceaccount.com \ + --scopes cloud-platform \ + --machine-type n1-highcpu-4 \ + --container-image "gcr.io/$PROJECT_ID/$BRANCH_NAME:$SHORT_SHA" \ + --tags seeder \ + --metadata-from-file startup-script=scripts/seeder-zfnd-org-startup.sh \ + --container-mount-host-path mount-path=/etc/dnsseeder,host-path=/etc/dnsseeder,mode=ro \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 86848a7..7817e8d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,7 +22,7 @@ RUN git clone --depth 1 --branch v${COREDNS_VERSION} https://github.com/coredns/ WORKDIR /go/src/github.com/coredns/coredns RUN echo "dnsseed:github.com/zcashfoundation/dnsseeder/dnsseed" >> /go/src/github.com/coredns/coredns/plugin.cfg -# Must be the same replace as in `dnsseeder`. Currently pointing to "main-zfnd" branch +# Must be the same replace as in `dnsseeder`. Currently pointing to "master" branch RUN echo "replace github.com/btcsuite/btcd => github.com/ZcashFoundation/btcd v0.22.0-beta.0.20220607000607-40dc9492aa42" >> /go/src/github.com/coredns/coredns/go.mod RUN go get github.com/zcashfoundation/dnsseeder/dnsseed@${DNSSEEDER_VERSION}