From 5087a5f9fb99bafaa25829df158e16ff19ad1071 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:16:39 -0500 Subject: [PATCH] chore: test out deploy script --- .github/scripts/deploy.ps1 | 3 ++ .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 .github/scripts/deploy.ps1 diff --git a/.github/scripts/deploy.ps1 b/.github/scripts/deploy.ps1 new file mode 100644 index 0000000..4919c51 --- /dev/null +++ b/.github/scripts/deploy.ps1 @@ -0,0 +1,3 @@ +#!/bin/pwsh + +Write-Host "Deploying to production..." \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6cf6c89..c6a7aa2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,27 +15,53 @@ on: - '**/*/README.md' - '**/*/Dockerfile' jobs: - build: - name: Build and push Docker image + # build: + # name: Build and push Docker image + # runs-on: ubuntu-latest + # outputs: + # version: ${{ steps.version.outputs.version }} + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + # - name: Login to Docker Hub + # uses: docker/login-action@v3 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: Create version tag + # id: version + # run: echo "version=$(date +%Y.%m.%d.%H%M%S)" >> $GITHUB_OUTPUT + # - name: Build and push server image + # working-directory: src/Blog + # run: | + # TAG=${{ secrets.DOCKERHUB_USERNAME }}/blog.stevanfreeborn.com:${{ steps.version.outputs.version }} + # docker build -t $TAG . + # docker push $TAG + deploy: + name: Deploy to server runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} + # needs: build steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Login to Docker Hub - uses: docker/login-action@v3 + - name: Copy files to server + uses: appleboy/scp-action@v0.1.7 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create version tag - id: version - run: echo "version=$(date +%Y.%m.%d.%H%M%S)" >> $GITHUB_OUTPUT - - name: Build and push server image - working-directory: src/Blog - run: | - TAG=${{ secrets.DOCKERHUB_USERNAME }}/blog.stevanfreeborn.com:${{ steps.version.outputs.version }} - docker build -t $TAG . - docker push $TAG \ No newline at end of file + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_KEY }} + source: ".github/scripts/deploy.ps1" + target: blog.stevanfreeborn.com + - name: Run deploy script + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_KEY }} + script: | + cd blog.stevanfreeborn.com + ./.github/scripts/deploy.ps1 \ No newline at end of file