Skip to content

dinushchathurya/push-docker-image-to-github-container-registry-using-github-action

Repository files navigation

Publish Docker Image to GitHub Container Registry

In here, the following workflow can use to publish the docker image to GitHub Container Registry (GCR) using GitHub Action. This GitHub action will be triggered every time a new Git tag is pushed to the GitHub repository.

Create Environment Variables

1.Create GitHub Personal Access Token in your profile developer settings page. Select following scopes:

  • repo
  • read:packages
  • write:packages

  • 2.Go to your GitHub repositorie's Settings => Secrets => Actions and create New Repsitory Secret. Name it GHCR_PAT and set the value to your created YOUR ACCESS TOKEN.

    Publish new Docker Image with version number

    As usual, stage your changes and then commit them. Then, run the folowing commands:

    git tag <your_tag> 
    

    Then run the following command to push changes to GitHub repository:

    git push origin <tag_name>
    

    The following workflow is designed to be triggered when a new Git tag is pushed project repository. Using the workflow, you can perform pushes to the repository (git push) without triggering this workflow. For example, when updating the project’s README file, you can run the following command:

    git push <branch_name>