Update README with VM and HOST variable information #61
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: Deploy Infra | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| env: | |
| REGISTRY: ghcr.io | |
| DOCKER_STACK_NAME: infra | |
| HOST: ${{ vars.HOST }} | |
| GIT_COMMIT_SHA: ${{ github.sha }} | |
| OWNER_NAME: nu31hackerspace | |
| USERNAME: ${{ vars.USERNAME }} | |
| PASSWORD: ${{ secrets.PASSWORD }} | |
| MQTT_TLS_DOMAIN: mqtt.gc.nu31.space | |
| PGWEB_GITHUB_CLIENT_ID: ${{ secrets.PGWEB_GITHUB_CLIENT_ID }} | |
| PGWEB_GITHUB_CLIENT_SECRET: ${{ secrets.PGWEB_GITHUB_CLIENT_SECRET }} | |
| PGWEB_OAUTH2_COOKIE_SECRET: ${{ secrets.PGWEB_OAUTH2_COOKIE_SECRET }} | |
| ROOT_SSH_PRIVATE_KEY: ${{ secrets.ROOT_SSH_PRIVATE_KEY }} | |
| MONGO_RS_KEYFILE_CONTENT: ${{ secrets.MONGO_RS_KEYFILE_CONTENT }} | |
| GCS_BUCKET: ${{ vars.GCS_BUCKET }} | |
| GCS_SA_KEY_BASE64: ${{ secrets.GCS_SA_KEY_BASE64 }} | |
| jobs: | |
| build-and-push: | |
| strategy: | |
| matrix: | |
| include: | |
| - name: mongo-rs-backup | |
| context: ./mongo-rs-backup | |
| image: mongo-rs-backup | |
| - name: caddy | |
| context: ./caddy | |
| image: caddy | |
| - name: caddy-backup | |
| context: ./caddy-backup | |
| image: caddy-backup | |
| - name: grafana | |
| context: ./grafana | |
| image: grafana | |
| - name: grafana-backup | |
| context: ./grafana-backup | |
| image: grafana-backup | |
| - name: telegraf | |
| context: ./telegraf | |
| image: telegraf | |
| - name: postgres-backup | |
| context: ./postgres-backup | |
| image: postgres-backup | |
| - name: mqtt | |
| context: ./mqtt | |
| image: mqtt | |
| - name: mqtt-backup | |
| context: ./mqtt-backup | |
| image: mqtt-backup | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ matrix.context }} | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.OWNER_NAME }}/${{ matrix.image }}:latest | |
| ${{ env.REGISTRY }}/${{ env.OWNER_NAME }}/${{ matrix.image }}:${{ github.sha }} | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Create env file | |
| run: | | |
| write_var() { printf "%s='%s'\n" "$1" "$(printenv "$1")" >> ./envfile; } | |
| > ./envfile | |
| write_var OWNER_NAME | |
| write_var GIT_COMMIT_SHA | |
| write_var USERNAME | |
| write_var PASSWORD | |
| write_var MONGO_RS_KEYFILE_CONTENT | |
| write_var GCS_BUCKET | |
| write_var GCS_SA_KEY_BASE64 | |
| write_var MQTT_TLS_DOMAIN | |
| write_var PGWEB_GITHUB_CLIENT_ID | |
| write_var PGWEB_GITHUB_CLIENT_SECRET | |
| write_var PGWEB_OAUTH2_COOKIE_SECRET | |
| - name: Docker Stack Deploy | |
| uses: cssnr/stack-deploy-action@v1 | |
| with: | |
| name: ${{ env.DOCKER_STACK_NAME }} | |
| file: docker-stack.yml | |
| host: ${{ env.HOST }} | |
| user: ${{ env.USERNAME }} | |
| ssh_key: ${{ env.ROOT_SSH_PRIVATE_KEY }} | |
| env_file: ./envfile | |