Skip to content

Commit 1403fa6

Browse files
committed
[N/A] Boilerplate Github files
1 parent 9462874 commit 1403fa6

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

.github/workflows/deploy.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: deploy
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build_deploy:
14+
name: Build and Deploy
15+
runs-on: ubuntu-latest
16+
env:
17+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup SSH key and known_hosts
23+
run: |
24+
mkdir -p -m 700 ~/.ssh
25+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
26+
ssh-add - <<< "${{ secrets.DEPLOY_KEY }}"
27+
ssh-keyscan ${{ secrets.DEPLOY_TARGET }} >> ~/.ssh/known_hosts
28+
ssh-keyscan ${{ secrets.DEPLOY_KIT_TARGET }} >> ~/.ssh/known_hosts
29+
30+
- name: Use Node.js 20
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: 20
34+
35+
# Set up composer caching
36+
- name: Cache Composer dependencies
37+
uses: actions/cache@v4
38+
with:
39+
path: /tmp/composer-cache
40+
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
41+
42+
# Build Blocks Toolkit
43+
- name: Build Blocks Toolkit plugin
44+
run: |
45+
npm ci
46+
npm run build
47+
working-directory: wp-content/plugins/viget-blocks-toolkit
48+
49+
# Deploy code
50+
- name: Deploy Starter
51+
run: |
52+
53+
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_TARGET }} "\
54+
sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\
55+
sudo rm -rf ${{ secrets.APP_PATH }}/wp-content/plugins/viget-blocks-toolkit &&\
56+
rsync -rlptzv --exclude="node_modules" ./wp-content/ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_TARGET }}:${{ secrets.APP_PATH }}/wp-content/
57+
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_TARGET }} "\
58+
sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\
59+
sudo chown -R ${{ secrets.DEPLOY_DAEMON }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content/plugins"
60+
61+
- name: Deploy Kit
62+
run: |
63+
64+
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_KIT_TARGET }} "\
65+
sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\
66+
sudo rm -rf ${{ secrets.APP_PATH }}/wp-content/plugins/viget-blocks-toolkit &&\
67+
rsync -rlptzv --exclude="node_modules" ./wp-content/ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_KIT_TARGET }}:${{ secrets.APP_PATH }}/wp-content/
68+
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_KIT_TARGET }} "\
69+
sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\
70+
sudo chown -R ${{ secrets.DEPLOY_DAEMON }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content/plugins"

.github/workflows/release.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Create release for any tag starting with 'v'
7+
8+
concurrency:
9+
group: release
10+
cancel-in-progress: true
11+
12+
jobs:
13+
release:
14+
name: Create GitHub Release
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Create GitHub Release
22+
run: |
23+
gh release create "$TAG" --verify-tag \
24+
--title "$TAG: $(date '+%Y-%m-%d')" \
25+
--generate-notes \
26+
--latest
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
TAG: ${{ github.ref_name }}

0 commit comments

Comments
 (0)