|
| 1 | +name: Deploy Docs |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout code |
| 12 | + uses: actions/checkout@v1 |
| 13 | + - name: Build and publish docker image |
| 14 | + uses: elgohr/Publish-Docker-Github-Action@master |
| 15 | + with: |
| 16 | + name: docs-storefrontcloud-io/v1:${{ github.sha }} |
| 17 | + registry: registry.storefrontcloud.io |
| 18 | + username: ${{ secrets.DOCS_CLOUD_USERNAME }} |
| 19 | + password: ${{ secrets.DOCS_CLOUD_PASSWORD }} |
| 20 | + workdir: docs |
| 21 | + dockerfile: Dockerfile |
| 22 | + buildoptions: "--compress" |
| 23 | + deploy: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + needs: build |
| 26 | + steps: |
| 27 | + - uses: chrnorm/deployment-action@releases/v1 |
| 28 | + name: Create GitHub deployment |
| 29 | + id: deployment |
| 30 | + with: |
| 31 | + token: "${{ github.token }}" |
| 32 | + target_url: https://docs.europe-west1.gcp.storefrontcloud.io/v1 |
| 33 | + environment: production |
| 34 | + initial_status: in_progress |
| 35 | + - name: Deploy on docs.europe-west1.gcp.storefrontcloud.io/v1 |
| 36 | + run: | |
| 37 | + if curl -s -H 'X-User-Id: ${{ secrets.DOCS_CLOUD_USERNAME }}' -H 'X-Api-Key: ${{ secrets.DOCS_CLOUD_PASSWORD }}' -H 'Content-Type: application/json' -X POST -d '{"code":"docs","region":"europe-west1.gcp","additionalApps":{"apps":[{"name":"docs-v1","tag":"${{ github.sha }}","image":"registry.storefrontcloud.io/docs-storefrontcloud-io/v1","path":"/v1","port":"80"}]}}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then |
| 38 | + echo "Instance updated" |
| 39 | + else |
| 40 | + echo "Something went wrong during the update process..." |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + - name: Update deployment status (success) |
| 44 | + if: success() |
| 45 | + uses: chrnorm/deployment-status@releases/v1 |
| 46 | + with: |
| 47 | + token: "${{ github.token }}" |
| 48 | + target_url: https://docs.europe-west1.gcp.storefrontcloud.io/v1 |
| 49 | + state: "success" |
| 50 | + description: Congratulations! The deploy is done. |
| 51 | + deployment_id: ${{ steps.deployment.outputs.deployment_id }} |
| 52 | + - name: Update deployment status (failure) |
| 53 | + if: failure() |
| 54 | + uses: chrnorm/deployment-status@releases/v1 |
| 55 | + with: |
| 56 | + token: "${{ github.token }}" |
| 57 | + target_url: https://docs.europe-west1.gcp.storefrontcloud.io/v1 |
| 58 | + description: Unfortunately, the instance hasn't been updated. |
| 59 | + state: "failure" |
| 60 | + deployment_id: ${{ steps.deployment.outputs.deployment_id }} |
0 commit comments