Created
July 14, 2023 16:07
-
-
Save nathan-roberts/013b3b184a52c4d05bf7864117c31436 to your computer and use it in GitHub Desktop.
Build SASS and Deploy via SSH
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: SCSS Build and Deploy | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 12 | |
- name: Install dependencies | |
run: | | |
npm install | |
working-directory: ./wp-content/themes/test-theme | |
- name: Build project | |
run: | | |
npm run build | |
working-directory: ./wp-content/themes/test-theme | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: dist | |
path: ./ # Change this path based on where the build output is located | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: dist | |
- name: rsync deployments | |
uses: burnett01/[email protected] | |
with: | |
switches: -avzr --delete | |
path: ./ # Ensure this path corresponds to the location of the downloaded artifact | |
remote_path: ${{ secrets.SSH_REMOTE_PATH }} | |
remote_host: ${{ secrets.SSH_SERVER }} | |
remote_user: ${{ secrets.SSH_USER }} | |
remote_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Send custom JSON data to Slack workflow | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"text": "Project Deployed", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Deployment Complete:" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: {{SLACK_WEBHOOK_URL}} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment