0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GitHub ActionsでFTP(S)経由によるファイルアップロード

Last updated at Posted at 2023-08-29
.github/workflows/main.yml
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v3
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: sv14460.xserver.jp
        username: test@xs679698.xsrv.jp
        password: ${{ secrets.ftp_password }}

必須項目

server

image.png

username

image.png

password

image.png

シークレットの設定方法

Settings > Secrets and variables > ActionsからNew repository secretをクリック

image.png

作成したパスワードを入力してAdd secretをクリック

image.png

アップロード先のフォルダー

.github/workflows/main.yml
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v3
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: sv14460.xserver.jp
        username: test@xs679698.xsrv.jp
        password: ${{ secrets.ftp_password }}
        server-dir: xs679698.xsrv.jp/public_html/

server-dir

アップロード先のフォルダー (サーバー上)、末尾にスラッシュ/を付ける必要があります

FTPS

protocol: ftpsを追加

on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v3
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: sv14460.xserver.jp
        username: test@xs679698.xsrv.jp
        password: ${{ secrets.ftp_password }}
        protocol: ftps
        server-dir: xs679698.xsrv.jp/public_html/

Exclude files

必要ならGitHub Actionsのワークフローファイルも除外しましょう

on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v3
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: sv14460.xserver.jp
        username: test@xs679698.xsrv.jp
        password: ${{ secrets.ftp_password }}
        protocol: ftps
        server-dir: xs679698.xsrv.jp/public_html/
        exclude: |
          **/.git*
          **/.git*/**
          **/node_modules/**
          **/.github*
          **/.github*/**
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?