Github Deployments and Github Actions for Continuous Releases

November 29th, 2020 147 Words

The Example for Continuous Deployment with Github Actions and AWS ECR uses a GitHub Deployment to trigger releases of tagged docker images. Using GitHub Actions, a task can be triggered for every created deployment.

Create a file in .github/workflows to store the configuration:

name: Release

on: deployment

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
      - name: Set $VERSION variable
        id: version
        run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)

      - name: Update your application
        run: echo "Use new tagged image ${{ steps.version.outputs.VERSION }}"

      - name: Update Deployment (success)
        if: success()
        uses: chrnorm/deployment-status@releases/v1
        with:
          token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
          state: "success"
          deployment_id: ${{ github.event.deployment.id }}

      - name: Update Deployment (failure)
        if: failure()
        uses: chrnorm/deployment-status@releases/v1
        with:
          token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
          state: "failure"
          deployment_id: ${{ github.event.deployment.id }}

Together with Continuous Deployment with Github Actions and AWS ECR and Semantic Releases With Github Actions this is a nice Event-Driven Delivery process.