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.
-
Create a new branch of code called
API
-
Edit one of your
deploy-docker.yml
workflow files -
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}}
-
Commit the file.
-
Open a pull request with the
API
branch into themain
branch. -
Merge the pull request.
-
You will now see the job run and deploy your Docker image, and update the deployment info in your repository.