GithubHelp home page GithubHelp logo

westonsteimel / action-docker-publish Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 31 KB

GitHub Action to build a Docker image and push to a container registry

License: MIT License

Dockerfile 6.46% Shell 93.54%

action-docker-publish's Introduction

This Action Publishes Docker Images to the GitHub Package Registry.

Background On The GitHub Package Registry (GPR):

From the docs:

The GitHub Package Registry allows you to develop your code and host your packages in one place. GitHub uses the README in your repository to generate the package's description, and you can edit it to reflect details about the package or installation process. GitHub adds metadata for each package version that includes links to the author, repository, commit SHA, version tags, and date.

The docs also contain relevant such as how to authenticate and naming conventions. Some noteable items about publishing Docker Images on GPR:

  • Docker Images are tied to a repository.

  • All images are named with the following nomenclature:

    docker.pkg.github.com/{OWNER}/{REPOSITORY}/{IMAGE_NAME}:{TAG}

OWNER and REPOSITORY refer to a unique repository on GitHub, such as tensorflow/tensorflow.

Automatic Tagging

This Action will automatically tag each image as follows:

{Image_Name}:{shortSHA}

Where:

  • Image_Name is provided by the user as an input.
  • shortSHA is the first 12 characters of the GitHub SHA that triggered the action.

Usage

Example Workflow That Uses This Action:

name: Publish Docker image to GitHub Package Registry
on: push
jobs:
  build:
    runs-on: ubuntu-latest 
    steps:

    - name: Copy Repo Files
      uses: actions/checkout@master

     #This Action Emits 2 Variables, IMAGE_SHA_NAME and IMAGE_URL 
     #which you can reference in subsequent steps
    - name: Publish Docker Image to GPR
      uses: machine-learning-apps/gpr-docker-publish@master
      id: docker
      with:
        USERNAME: ${{ secrets.DOCKER_USERNAME }}
        PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
        IMAGE_NAME: 'test-docker-action'
        DOCKERFILE_PATH: 'argo/gpu.Dockerfile'
        BUILD_CONTEXT: 'argo/'

    # This second step is illustrative and shows how to reference the 
    # output variables.  This is completely optional.
    - name: Show outputs of pervious step
      run: |
        echo "The name:tag of the Docker Image is: $VAR1"
        echo "The docker image is hosted at $VAR2"
      env:
        VAR1: ${{ steps.docker.outputs.IMAGE_SHA_NAME }}
        VAR2: ${{ steps.docker.outputs.IMAGE_URL }}

Mandatory Inputs

  1. USERNAME the login username, most likely your github handle. This username must have write access to the repo where the action is called.
  2. PASSWORD Your GitHub password that has write access to the repo where this action is called.
  3. IMAGE_NAME is the name of the image you would like to push
  4. DOCKERFILE_PATH: The full path (including the filename) relative to the root of the repository that contains the Dockerfile that specifies your build.
  5. BUILD_CONTEXT: The directory for the build context. See these docs for more information on the definition of build context.

Optional Inputs

  1. cache: if value is true, attempts to use the last pushed image as a cache. Default value is false.

Outputs

You can reference the outputs of an action using expression syntax, as illustrated in the Example Pipeline above.

  1. IMAGE_SHA_NAME: This is the {Image_Name}:{shortSHA} as described above.
  2. IMAGE_URL: This is the URL on GitHub where you can view your hosted Docker images. This will always be located at https://github.com/{OWNER}/{REPOSITORY}/packages in reference to the repository where the action was called.

These outputs are merely provided as convenience incase you want to use these values in subsequent steps.

action-docker-publish's People

Contributors

hamelsmu avatar westonsteimel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.