|
| 1 | +name: Service Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [dev] |
| 6 | + |
| 7 | +jobs: |
| 8 | + docker: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + name: Push docker image |
| 11 | + steps: |
| 12 | + - name: App version |
| 13 | + run: echo Picked the app version ${{ github.sha }} |
| 14 | + |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v2.3.4 |
| 17 | + |
| 18 | + - uses: actions/setup-node@v2 |
| 19 | + with: |
| 20 | + node-version: '14.17.6' |
| 21 | + |
| 22 | + - name: Publish to Registry |
| 23 | + uses: docker/build-push-action@v1 |
| 24 | + with: |
| 25 | + registry: docker.pkg.github.com |
| 26 | + username: ${{ github.actor }} |
| 27 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + repository: '${{ github.actor }}/n0th1ng-else.github.io/n0th1ng-else-blog' |
| 29 | + tag_with_sha: true |
| 30 | + build_args: APP_VERSION=${{ github.sha }},GH_AUTHOR_LOGIN=${{ secrets.GH_AUTHOR_LOGIN }},GH_AUTHOR_LINKED_IN=${{ secrets.GH_AUTHOR_LINKED_IN }},GH_AUTHOR_TELEGRAM=${{ secrets.GH_AUTHOR_TELEGRAM }},GH_AUTHOR_MEDIUM=${{ secrets.GH_AUTHOR_MEDIUM }},GH_AUTHOR_HABR=${{ secrets.GH_AUTHOR_HABR }},GH_AUTHOR_NPM=${{ secrets.GH_AUTHOR_NPM }},GH_AUTHOR_TWITTER=${{ secrets.GH_AUTHOR_TWITTER }},GH_AUTHOR_DEVTO=${{ secrets.GH_AUTHOR_DEVTO }} |
| 31 | + |
| 32 | + heroku: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + name: Deploy to Heroku |
| 35 | + steps: |
| 36 | + - name: Fetch the last commit in the PR |
| 37 | + id: sha |
| 38 | + uses: actions/github-script@v4 |
| 39 | + with: |
| 40 | + result-encoding: string |
| 41 | + script: | |
| 42 | + const { owner, repo, number } = context.issue; |
| 43 | + const pr = await github.pulls.get({ |
| 44 | + owner, |
| 45 | + repo, |
| 46 | + pull_number: number, |
| 47 | + }); |
| 48 | + return pr.data.head.sha |
| 49 | +
|
| 50 | + - name: App version |
| 51 | + run: echo Picked the app version ${{ github.sha }} |
| 52 | + |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v2.3.4 |
| 55 | + |
| 56 | + - uses: actions/setup-node@v2 |
| 57 | + with: |
| 58 | + node-version: '14.17.6' |
| 59 | + |
| 60 | + - name: Docker login |
| 61 | + run: echo ${{ env.D_PWD }} | docker login --username=${{ env.D_LOGIN }} ${{ env.D_REGISTRY }} --password-stdin |
| 62 | + env: |
| 63 | + D_LOGIN: ${{ secrets.HEROKU_EMAIL }} |
| 64 | + D_PWD: ${{ secrets.HEROKU_API_KEY }} |
| 65 | + D_REGISTRY: registry.heroku.com |
| 66 | + |
| 67 | + - name: Push docker image |
| 68 | + run: | |
| 69 | + heroku container:${{ env.D_ACTION }} web --app ${{ env.D_NAME }} --arg \ |
| 70 | + APP_VERSION=${{ env.D_VERSION }},\ |
| 71 | + GH_AUTHOR_LOGIN=${{ secrets.GH_AUTHOR_LOGIN }},\ |
| 72 | + GH_AUTHOR_LINKED_IN=${{ secrets.GH_AUTHOR_LINKED_IN }},\ |
| 73 | + GH_AUTHOR_TELEGRAM=${{ secrets.GH_AUTHOR_TELEGRAM }},\ |
| 74 | + GH_AUTHOR_MEDIUM=${{ secrets.GH_AUTHOR_MEDIUM }},\ |
| 75 | + GH_AUTHOR_HABR=${{ secrets.GH_AUTHOR_HABR }},\ |
| 76 | + GH_AUTHOR_NPM=${{ secrets.GH_AUTHOR_NPM }},\ |
| 77 | + GH_AUTHOR_TWITTER=${{ secrets.GH_AUTHOR_TWITTER }},\ |
| 78 | + GH_AUTHOR_DEVTO=${{ secrets.GH_AUTHOR_DEVTO }} |
| 79 | + env: |
| 80 | + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} |
| 81 | + D_ACTION: push |
| 82 | + D_NAME: ${{ secrets.HEROKU_APP_NAME }} |
| 83 | + D_VERSION: ${{ github.sha }} |
| 84 | + |
| 85 | + - name: Release docker image |
| 86 | + run: heroku container:${{ env.D_ACTION }} web --app ${{ env.D_NAME }} |
| 87 | + env: |
| 88 | + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} |
| 89 | + D_ACTION: release |
| 90 | + D_NAME: ${{ secrets.HEROKU_APP_NAME }} |
| 91 | + |
| 92 | + - name: Sleep for around 1 minute |
| 93 | + run: sleep 60s |
| 94 | + shell: bash |
| 95 | + |
| 96 | + - name: Toggle healthcheck handler |
| 97 | + uses: fjogeleit/http-request-action@master |
| 98 | + with: |
| 99 | + url: https://${{ secrets.HEROKU_APP_NAME }}.herokuapp.com/status |
| 100 | + method: GET |
0 commit comments