diff --git a/.github/workflows/build-and-deploy-plugins.yml b/.github/workflows/build-and-deploy-plugins.yml new file mode 100644 index 0000000..2b8f2db --- /dev/null +++ b/.github/workflows/build-and-deploy-plugins.yml @@ -0,0 +1,71 @@ +name: Build and Upload Plugins + +on: + workflow_dispatch: + +jobs: + build-and-upload: + runs-on: ubuntu-latest + env: + PLUGIN_OUTPUT_DIR: ./generated + ZIP_FILE: plugins_bundle.zip + + steps: + - name: Checkout this repo + uses: actions/checkout@v4 + + - name: Set up Git + run: | + git config --global url."https://${{ secrets.PAT_GITHUB }}:@github.com/beckn/beckn-onix.git".insteadOf "https://github.com/" + git config --global url."https://${{ secrets.GERRIT_USERNAME }}:${{ secrets.GERRIT_PAT }}@open-networks.googlesource.com/onix-dev/".insteadOf "https://gerrit.example.com/" + + - name: Clone GitHub and Gerrit plugin repos + run: | + # Example GitHub clone + git -b beckn-onix-v1.0-develop clone https://github.com/beckn/beckn-onix.git github-repo + + # Example Gerrit clone + git clone https://open-networks.googlesource.com/onix-dev/ + + - name: Build Go plugins in Docker + run: | + set -e + mkdir -p $PLUGIN_OUTPUT_DIR + BUILD_CMDS="" + + # GitHub plugins + for dir in beckn-onix-v1.0-develop/pkg/plugin/implementation/*; do + plugin=$(basename "$dir") + BUILD_CMDS+="go build -buildmode=plugin -buildvcs=false -o ${PLUGIN_OUTPUT_DIR}/${plugin}.so ./${dir}/cmd && " + done + + # Gerrit plugins + for dir in onix-dev/plugins/*; do + plugin=$(basename "$dir") + BUILD_CMDS+="go build -buildmode=plugin -buildvcs=false -o ${PLUGIN_OUTPUT_DIR}/${plugin}.so ./${dir}/cmd && " + done + + BUILD_CMDS=${BUILD_CMDS%" && "} + docker run --rm -v "$(pwd)":/app -w /app golang:1.24-bullseye sh -c "$BUILD_CMDS" + + - name: Zip the plugin binaries + run: | + cd $PLUGIN_OUTPUT_DIR + zip -r ../$ZIP_FILE *.so + cd .. + + - name: Authenticate to GCP + run: | + echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}" > gcloud-key.json + gcloud auth activate-service-account --key-file=gcloud-key.json + gcloud config set project trusty-relic-370809 + env: + GOOGLE_APPLICATION_CREDENTIALS: gcloud-key.json + + - name: Upload to GCS + run: | + gsutil -m cp -r $ZIP_FILE gs://${GCS_BUCKET}/ + + - name: Cleanup + run: | + rm -rf $PLUGIN_OUTPUT_DIR $ZIP_FILE gcloud-key.json