no fadein #70
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 stacktastic | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - staging | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| env: | |
| IMAGE_TAG: ${{ github.sha }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| run: | | |
| docker build --pull -t stacktastic-${{ github.ref_name }}:${{ github.sha }} . | |
| docker save stacktastic-${{ github.ref_name }}:${{ github.sha }} | gzip > image.tar.gz | |
| - name: Copy image and docker-compose to server | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| source: "image.tar.gz,docker-compose.${{ github.ref_name }}.yml" | |
| target: "~/stacktastic/${{ github.ref_name }}/" | |
| - name: SSH and deploy | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| script: | | |
| set -e | |
| cd ~/stacktastic/${{ github.ref_name }} | |
| gunzip -f image.tar.gz | |
| docker load < image.tar | |
| API_KEY_FRIENDLY_CAPTCHA=${{ secrets.API_KEY_FRIENDLY_CAPTCHA }} \ | |
| CONTACT_RECEIVER=${{ secrets.CONTACT_RECEIVER }} \ | |
| MAIL_HOST=${{ secrets.MAIL_HOST }} \ | |
| MAIL_PORT=${{ secrets.MAIL_PORT }} \ | |
| MAIL_USER=${{ secrets.MAIL_USER }} \ | |
| MAIL_PASS=${{ secrets.MAIL_PASS }} \ | |
| FRIENDLY_CAPTCHA_SECRET=${{ secrets.FRIENDLY_CAPTCHA_SECRET }} \ | |
| CAPTCHA_SECRET=${{ secrets.CAPTCHA_SECRET }} \ | |
| IMAGE_TAG=${{ github.sha }} docker-compose -f docker-compose.${{ github.ref_name }}.yml up -d --force-recreate | |
| rm -f image.tar |