|
| 1 | +--- |
| 2 | +name: 'deploy' |
| 3 | + |
| 4 | +# yamllint disable-line rule:truthy |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - master |
| 9 | + |
| 10 | +jobs: |
| 11 | + deploy: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Cloning repo |
| 15 | + uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Create deployment |
| 20 | + id: create_deployment |
| 21 | + |
| 22 | + with: |
| 23 | + route: POST /repos/:repository/deployments |
| 24 | + repository: ${{ github.repository }} |
| 25 | + ref: ${{ github.sha }} |
| 26 | + environment: production |
| 27 | + required_contexts: '[]' |
| 28 | + production_environment: true |
| 29 | + env: |
| 30 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 31 | + |
| 32 | + - name: Set deployment status to in progress |
| 33 | + |
| 34 | + with: |
| 35 | + route: POST /repos/:repository/deployments/:deployment/statuses |
| 36 | + repository: ${{ github.repository }} |
| 37 | + deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} |
| 38 | + environment: production |
| 39 | + environment_url: https://example.com |
| 40 | + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 41 | + state: in_progress |
| 42 | + mediaType: '{"previews": ["flash", "ant-man"]}' # required for setting in_progress state and environment_url |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 45 | + |
| 46 | + - name: Push to dokku |
| 47 | + uses: dokku/github-action@master |
| 48 | + with: |
| 49 | + git_remote_url: 'ssh://[email protected]:22/appname' |
| 50 | + ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 51 | + |
| 52 | + - name: Set deployment status to success |
| 53 | + |
| 54 | + with: |
| 55 | + route: POST /repos/:repository/deployments/:deployment/statuses |
| 56 | + repository: ${{ github.repository }} |
| 57 | + deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} |
| 58 | + environment: production |
| 59 | + environment_url: https://example.com |
| 60 | + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 61 | + mediaType: '{"previews": ["ant-man"]}' # required for environment_url |
| 62 | + state: success |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 65 | + |
| 66 | + - name: Set deployment status to failure |
| 67 | + |
| 68 | + if: failure() |
| 69 | + with: |
| 70 | + route: POST /repos/:repository/deployments/:deployment/statuses |
| 71 | + repository: ${{ github.repository }} |
| 72 | + deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} |
| 73 | + environment: production |
| 74 | + environment_url: https://example.com |
| 75 | + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 76 | + mediaType: '{"previews": ["ant-man"]}' # required for environment_url |
| 77 | + state: failure |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
0 commit comments