This repository was archived by the owner on Nov 4, 2025. It is now read-only.
Merge pull request #3 from Burhan-Q/patch-1 #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Builds For Voxel51 Discord Bot | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| paths: | |
| - 'voxelbot/**' | |
| - 'ansible/**' | |
| - 'dockerfile' | |
| - 'docker-compose.yaml' | |
| - '.github/workflows/build-and-publish.yml' | |
| concurrency: | |
| group: "${{ github.ref_name }}-build-and-deploy" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: 'write' | |
| id-token: 'write' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| project_id: ${{ secrets.GCP_PROJECT }} | |
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
| workload_identity_provider: ${{ secrets.ORG_GOOGLE_WORKLOAD_IDP }} | |
| - name: Set Up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| with: | |
| install_components: 'beta' | |
| - name: Docker login | |
| run: | | |
| gcloud auth print-access-token | docker login \ | |
| -u oauth2accesstoken \ | |
| --password-stdin "https://${{ secrets.GCP_LOCATION }}-docker.pkg.dev" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| file: dockerfile | |
| context: . | |
| tags: ${{ secrets.GCP_LOCATION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GCP_DOCKER_REPOSITORY }}/voxel51-discordbot:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,node=max | |
| - name: Deploy via ansible | |
| shell: bash | |
| env: | |
| DOCKER_REGISTRY: "${{ secrets.GCP_LOCATION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GCP_DOCKER_REPOSITORY }}/" | |
| GCP_SM_KEY: "${{ secrets.GCP_SM_KEY }}" | |
| TAG: ${{ github.sha }} | |
| GCP_COMPUTE_SERVER_NAME: "${{ secrets.GCP_COMPUTE_SERVER_NAME }}" | |
| GCP_LOCATION: ${{ secrets.GCP_LOCATION }} | |
| GCP_PROJECT: ${{ secrets.GCP_PROJECT }} | |
| run: | | |
| pushd ansible | |
| yq -i ".projects |= [\"$GCP_PROJECT\"]" ./inventory/gcp.yml | |
| yq -i ".zones |= [\"$GCP_LOCATION\"]" ./inventory/gcp.yml | |
| sudo pipx inject ansible-core -r requirements.txt | |
| ansible-playbook site.yml | |
| popd |