|
8 | 8 | - completed
|
9 | 9 |
|
10 | 10 | jobs:
|
11 |
| - web-deploy: |
12 |
| - name: 🎉 Deploy |
| 11 | + deploy: |
| 12 | + name: 🎉 Deploy to FTP |
13 | 13 | runs-on: ubuntu-latest
|
| 14 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
14 | 15 | steps:
|
15 |
| - - name: 🚚 Get latest code |
16 |
| - uses: actions/checkout@v2 |
17 |
| - - name: Current repo dir |
18 |
| - run: | |
19 |
| - echo test the checkout action, |
20 |
| - ls -a |
| 16 | + - name: 🚚 Get latest code |
| 17 | + uses: actions/checkout@v2 |
| 18 | + |
| 19 | + - name: ℹ️ Current repo dir |
| 20 | + run: | |
| 21 | + echo "Testing the checkout action..." |
| 22 | + ls -a |
| 23 | +
|
| 24 | + - name: 🚧 Build project |
| 25 | + run: | |
| 26 | + echo "Building the project..." |
| 27 | + pnpm install |
| 28 | + pnpm build |
| 29 | + mkdir -p build |
| 30 | + echo "Exporting to /build ..." |
| 31 | + cp -r .next static public build/ |
| 32 | + env: |
| 33 | + WORDPRESS_GRAPHQL_ENDPOINT: ${{ secrets.WORDPRESS_GRAPHQL_ENDPOINT }} |
| 34 | + |
21 | 35 |
|
22 |
| - - name: 📂 Sync files |
23 |
| - uses: SamKirkland/FTP-Deploy-Action@4.1.0 |
24 |
| - with: |
25 |
| - server: ${{ secrets.FTP_SERVER }} |
26 |
| - server-dir: ${{ secrets.FTP_DIR }} |
27 |
| - dangerous-clean-slate: true |
28 |
| - username: ${{ secrets.FTP_USER }} |
29 |
| - password: ${{ secrets.FTP_PASSWORD }} |
30 |
| - local-dir: ./build/ |
| 36 | + - name: 💾 Backup files on FTP |
| 37 | + run: | |
| 38 | + # Install lftp if not available |
| 39 | + sudo apt-get update |
| 40 | + sudo apt-get install -y lftp |
| 41 | +
|
| 42 | + # Define FTP server details |
| 43 | + FTP_SERVER=${{ secrets.FTP_SERVER }} |
| 44 | + FTP_USER=${{ secrets.FTP_USER }} |
| 45 | + FTP_PASSWORD=${{ secrets.FTP_PASSWORD }} |
| 46 | + FTP_DIR=${{ secrets.FTP_DIR }} |
| 47 | + FTP_BAK_DIR=${{ secrets.FTP_BAK_DIR }} |
| 48 | +
|
| 49 | + # Clear backup directory |
| 50 | + lftp -u "$FTP_USER","$FTP_PASSWORD" ftps://$FTP_SERVER << EOF |
| 51 | + set ftp:ssl-allow yes |
| 52 | + mirror --delete --verbose $FTP_BAK_DIR /tmp/empty-dir |
| 53 | + rm -rf /tmp/empty-dir/* |
| 54 | + mirror --reverse --verbose $FTP_BAK_DIR /tmp/empty-dir |
| 55 | + quit |
| 56 | + EOF |
| 57 | +
|
| 58 | + # Move files from FTP_DIR to FTP_BAK_DIR |
| 59 | + lftp -u "$FTP_USER","$FTP_PASSWORD" ftps://$FTP_SERVER << EOF |
| 60 | + set ftp:ssl-allow yes |
| 61 | + mirror --reverse --verbose $FTP_DIR $FTP_BAK_DIR |
| 62 | + quit |
| 63 | + EOF |
| 64 | + |
| 65 | + #- name: 📂 Sync files |
| 66 | + # uses: SamKirkland/FTP-Deploy-Action@4.3.5 |
| 67 | + # with: |
| 68 | + #server: ${{ secrets.FTP_SERVER }} |
| 69 | + #server-dir: ${{ secrets.FTP_DIR }} |
| 70 | + #dangerous-clean-slate: true |
| 71 | + #username: ${{ secrets.FTP_USER }} |
| 72 | + #password: ${{ secrets.FTP_PASSWORD }} |
| 73 | + #local-dir: ./build/ |
| 74 | + #protocol: ftps |
0 commit comments