Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.46 KB

08.B-Add-Deployment-API.md

File metadata and controls

42 lines (34 loc) · 1.46 KB

Utilizing GitHub Deployment API

This exercise will walk you through utilizing the Github Deployment API on your current repository.

The objective of the Deployment API is to help showcase and link your environments to the events that created them.

Update your GitHub Action workflow file

  1. Create a new branch of code called API

  2. Edit one of your deploy-docker.yml workflow files

  3. Copy the code before and after the deployment:

    # Update deployment API
    - name: start deployment
      uses: bobheadxi/[email protected]
      id: deployment
      with:
        step: start
        token: ${{ secrets.GITHUB_TOKEN }}
        env: Production
    
    # ... Code that deploys the docker image to an environment here...
    
    # Update Deployment API
    - name: update deployment status
      uses: bobheadxi/[email protected]
      if: always()
      with:
        step: finish
        token: ${{ secrets.GITHUB_TOKEN }}
        status: ${{ job.status }}
        deployment_id: ${{ steps.deployment.outputs.deployment_id }}
        env_url: https://github.com/orgs/${{github.owner}}/packages?repo_name=${{github.repository}}
  4. Commit the file.

  5. Open a pull request with the API branch into the main branch.

  6. Merge the pull request.

  7. You will now see the job run and deploy your Docker image, and update the deployment info in your repository.

Linkage