Deploy #31
This file contains hidden or 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
| # https://maxschmitt.me/posts/github-actions-ssh-key | |
| --- | |
| name: Deploy | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Deployment Environment' | |
| required: true | |
| default: 'staging' | |
| type: choice | |
| options: | |
| - staging | |
| - production | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Add SSH key | |
| run: | | |
| mkdir -p /home/runner/.ssh | |
| echo "${{ secrets.DOKKU_HOST_KEY }}" >> /home/runner/.ssh/known_hosts | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" >> /home/runner/.ssh/github_actions | |
| chmod 600 /home/runner/.ssh/github_actions | |
| echo 'Host dokku | |
| Hostname ${{ secrets.DOKKU_HOST_URL }} | |
| IdentityFile /home/runner/.ssh/github_actions | |
| User dokku' >> /home/runner/.ssh/config | |
| - name: Init Git and deploy | |
| run: | | |
| git config --global user.email "actions@github.com" | |
| git config --global user.name "GitHub actions" | |
| git remote add dokku dokku:${{ inputs.environment }} | |
| git push dokku master -f |