Merge pull request #1305 from podverse/develop #412
This file contains 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: master-branch | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Read node from package.json | |
uses: culshaw/read-package-node-version-actions@v1 | |
id: package-node-version | |
- | |
name: send deploying message to Matrix Alerts room | |
uses: s3krit/[email protected] | |
with: | |
room_id: ${{ secrets.MATRIX_ALERTS_ROOM_ID }} | |
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} | |
message: "Deploying podverse-web ${{ steps.package-node-version.outputs.version }} to prod..." | |
server: ${{ secrets.MATRIX_SERVER }} | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: podverse/podverse_web:latest,podverse/podverse_web:${{ steps.package-node-version.outputs.version }} | |
- | |
name: Tailscale | |
uses: tailscale/github-action@main | |
with: | |
authkey: ${{ secrets.TAILSCALE_AUTHKEY }} | |
- | |
name: log into prod, then deploy latest prod image | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PROD_SSH_HOST }} | |
username: ${{ secrets.PROD_SSH_USERNAME }} | |
key: ${{ secrets.PROD_SSH_PRIVATE_KEY }} | |
command_timeout: 60m | |
script: | | |
docker stop podverse_web_prod | |
docker rm podverse_web_prod | |
docker image rm podverse/podverse_web:latest | |
docker compose -f /opt/podverse-ops/docker-compose/prod/srv/docker-compose.yml up --quiet-pull -d podverse_web | |
- | |
name: send deploy finished message to Matrix Alerts room | |
uses: s3krit/[email protected] | |
with: | |
room_id: ${{ secrets.MATRIX_ALERTS_ROOM_ID }} | |
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} | |
message: "podverse-web ${{ steps.package-node-version.outputs.version }} has finished deploying to prod 🎉" | |
server: ${{ secrets.MATRIX_SERVER }} |