|
| 1 | +name: deploy-edgecreator |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | +jobs: |
| 6 | + deploy: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + environment: production |
| 9 | + steps: |
| 10 | + - name: Check out repository |
| 11 | + uses: actions/checkout@master |
| 12 | + |
| 13 | + - name: Download .env file |
| 14 | + uses: nicklasfrahm/scp-action@main |
| 15 | + with: |
| 16 | + direction: download |
| 17 | + host: ${{ secrets.PRODUCTION_SSH_HOST }} |
| 18 | + fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }} |
| 19 | + username: ${{ secrets.PRODUCTION_SSH_USER }} |
| 20 | + key: ${{ secrets.PRODUCTION_SSH_KEY }} |
| 21 | + source: /home/bperel/workspace/edgecreator-next/.env.prod |
| 22 | + target: .env.prod |
| 23 | + |
| 24 | + - name: Set up Docker Buildx |
| 25 | + uses: docker/setup-buildx-action@v1 |
| 26 | + |
| 27 | + - name: Login to GitHub Container Registry |
| 28 | + uses: docker/login-action@v1 |
| 29 | + with: |
| 30 | + registry: ghcr.io |
| 31 | + username: bperel |
| 32 | + password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} |
| 33 | + |
| 34 | + - name: Build and push runtime image |
| 35 | + uses: docker/build-push-action@v2 |
| 36 | + with: |
| 37 | + context: . |
| 38 | + platforms: linux/x86_64 |
| 39 | + push: true |
| 40 | + tags: | |
| 41 | + ghcr.io/bperel/edgecreator:latest |
| 42 | +
|
| 43 | + - name: Recreate container |
| 44 | + uses: appleboy/ssh-action@v0.1.4 |
| 45 | + env: |
| 46 | + DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }} |
| 47 | + with: |
| 48 | + host: ${{ secrets.PRODUCTION_SSH_HOST }} |
| 49 | + username: ${{ secrets.PRODUCTION_SSH_USER }} |
| 50 | + key: ${{ secrets.PRODUCTION_SSH_KEY }} |
| 51 | + command_timeout: 2m |
| 52 | + envs: DOCKER_REGISTRY_TOKEN |
| 53 | + script: | |
| 54 | + cd workspace/edgecreator-next |
| 55 | + echo $DOCKER_REGISTRY_TOKEN | docker login ghcr.io -u bperel --password-stdin |
| 56 | + docker-compose pull && docker-compose up -d --force-recreate |
0 commit comments