|
71 | 71 | with: |
72 | 72 | # ruby-version: 3.0.1 # Not needed with a .ruby-version file |
73 | 73 | bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
74 | | - - uses: miloserdow/capistrano-deploy@master |
| 74 | + - uses: miloserdow/capistrano-deploy@v3 # you can use miloserdow/capistrano-deploy@master for the cuurent stable dev version |
75 | 75 | with: |
76 | 76 | target: development # Defines the environment that will be used for the deployment |
77 | 77 | deploy_key: ${{ secrets.DEPLOY_ENC_KEY }} # Name of the variable configured in Settings/Secrets of your github project |
78 | 78 | ``` |
| 79 | +
|
| 80 | +## Example running this action with custom commands |
| 81 | +In this example we are starting rails and Sidekiq with Capistrano |
| 82 | +
|
| 83 | +### Personal access token |
| 84 | +You need to create a personal access token with "repo" access like described here: |
| 85 | +https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token |
| 86 | +
|
| 87 | +### Dispatch workflow |
| 88 | +Create a new dispatch workflow like described here: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-a-workflow-dispatch-event |
| 89 | +
|
| 90 | +### Workflow file: |
| 91 | +```yml |
| 92 | +name: Start Rails and Sidekiq with Capistrano |
| 93 | + |
| 94 | +on: |
| 95 | + workflow_dispatch: |
| 96 | + inputs: |
| 97 | + environment: |
| 98 | + description: "The environment to deploy" |
| 99 | + required: true |
| 100 | + |
| 101 | +jobs: |
| 102 | + deploy: |
| 103 | + runs-on: ubuntu-latest |
| 104 | + steps: |
| 105 | + - name: Checkout |
| 106 | + uses: actions/checkout@v2 |
| 107 | + - name: Turnstyle |
| 108 | + uses: softprops/turnstyle@master |
| 109 | + env: |
| 110 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 111 | + with: |
| 112 | + abort-after-seconds: 3600 |
| 113 | + - name: Set up Ruby |
| 114 | + uses: ruby/setup-ruby@v1 |
| 115 | + with: |
| 116 | + ruby-version: 2.6.6 |
| 117 | + bundler-cache: true |
| 118 | + - name: Deploy |
| 119 | + uses: kaspernj/capistrano-deploy@custom-capistrano-command |
| 120 | + with: |
| 121 | + capistrano_commands: '["puma:start", "sidekiq:start"]' |
| 122 | + target: ${{ github.event.inputs.environment }} |
| 123 | + deploy_key: ${{ secrets.DEPLOY_ENC_KEY }} |
| 124 | +``` |
| 125 | +
|
| 126 | +### Curl command |
| 127 | +```bash |
| 128 | +curl \ |
| 129 | + -X POST \ |
| 130 | + -H "Accept: application/vnd.github.v3+json" \ |
| 131 | + -H "Authorization: Bearer $PERSONAL_GITHUB_TOKEN" \ |
| 132 | + https://api.github.com/repos/$GITHUB_USERNAME/$GITHUB_REPO_NAME/actions/workflows/$WORKFLOW_FILE_NAME/dispatches \ |
| 133 | + -d "{\"ref\":\"master\",\"inputs\":{\"environment\":\"$ENVIRONMENT_TO_DEPLOY\"}}" |
| 134 | +``` |
| 135 | +This command makes Github start Rails and Sidekiq at the deployment. |
0 commit comments