All Projects → matootie → github-docker

matootie / github-docker

Licence: MIT License
⚓ Build and publish your repository as a Docker image and push it to GitHub Package Registry in one step.

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to github-docker

Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps 📱 using Github Actions 💊 + Firebase Distribution 🎉
Stars: ✭ 37 (+12.12%)
Mutual labels:  continuous-delivery, github-actions
actions
Set of actions for implementing CI/CD with werf and GitHub Actions
Stars: ✭ 67 (+103.03%)
Mutual labels:  continuous-delivery, github-actions
Cml
♾️ CML - Continuous Machine Learning | CI/CD for ML
Stars: ✭ 2,843 (+8515.15%)
Mutual labels:  continuous-delivery, github-actions
noise-php
A starter-kit for your PHP project.
Stars: ✭ 52 (+57.58%)
Mutual labels:  continuous-delivery, github-actions
pandoc-action
github action to run pandoc, soft-deprecated ->
Stars: ✭ 39 (+18.18%)
Mutual labels:  continuous-delivery, github-actions
bump-everywhere
🚀 Automate versioning, changelog creation, README updates and GitHub releases using GitHub Actions,npm, docker or bash.
Stars: ✭ 24 (-27.27%)
Mutual labels:  continuous-delivery, github-actions
terraform-provider-spinnaker
Terraform Provider to manage spinnaker pipelines
Stars: ✭ 36 (+9.09%)
Mutual labels:  continuous-delivery
lychee-action
Github action to check for broken links in Markdown, HTML, and text files using lychee, a fast link checker written in Rust.
Stars: ✭ 89 (+169.7%)
Mutual labels:  github-actions
hygieia
CapitalOne DevOps Dashboard
Stars: ✭ 3,697 (+11103.03%)
Mutual labels:  continuous-delivery
arduino-lint-action
GitHub Actions action to check Arduino projects for problems
Stars: ✭ 20 (-39.39%)
Mutual labels:  github-actions
prathimacode-hub
Hello everyone, Welcome to my GitHub README profile. Glad to see you here! Check out this repository to view my work and learn more about me. Don't just star it, fork it as well.📢✌️
Stars: ✭ 53 (+60.61%)
Mutual labels:  github-actions
aur-publish-docker-action
Github Action to publish an AUR package
Stars: ✭ 13 (-60.61%)
Mutual labels:  github-actions
minesweeper
💣Minesweeper game written with React
Stars: ✭ 18 (-45.45%)
Mutual labels:  github-actions
flagsmith-nodejs-client
Flagsmith Node JS Client. Flagsmith lets you manage features flags across web, mobile and server side applications. Get builds out faster. Control who has access to new features.
Stars: ✭ 13 (-60.61%)
Mutual labels:  continuous-delivery
delete-run-artifacts-action
github action to delete artifacts at the end of a workflow run
Stars: ✭ 21 (-36.36%)
Mutual labels:  github-actions
purescript-github-actions-toolkit
PureScript wrapper around GitHub's Actions Toolkit
Stars: ✭ 21 (-36.36%)
Mutual labels:  github-actions
stable-systems-checklist
An opinionated list of attributes and policies that need to be met in order to establish a stable software system.
Stars: ✭ 43 (+30.3%)
Mutual labels:  continuous-delivery
profile-readme-stats
Showcase your github stats on your profile README.md
Stars: ✭ 144 (+336.36%)
Mutual labels:  github-actions
maven-settings-action
This action setup maven settings.xml
Stars: ✭ 39 (+18.18%)
Mutual labels:  github-actions
misspell-fixer-action
📝Automatically fixes typos and mistakes in your source code and docs!
Stars: ✭ 123 (+272.73%)
Mutual labels:  github-actions

GitHub Docker Action

Disclaimer

I originally wrote this when GitHub Actions was very new, and the setup you had to use to push images using Docker's provided actions was not very clean. I wanted to make a one-click tool. This tool still works, however GitHub Actions has been around for a while now and Docker has really improved their provided actions. My honest recommendation to you is that you try using Docker Build-Push Action. It's what I use now. It has plenty more features, and uses Buildx. This repository will always have a place in my heart as the project that really got me into GitHub Actions.

Build and publish your repository as a Docker image and push it to GitHub Package Registry or GitHub Container Registry in one easy step.

GitHub Release

For help updating, view the change logs. If you need additional help feel free to submit an issue.

Table of Contents

Inputs

Name Requirement Description
accessToken Required GitHub Access Token to log in using. Must have write permissions for packages. Recommended set up would be to use the provided GitHub Token for your repository; ${{ github.token }}.
imageName Optional The desired name for the image. Defaults to current repository name.
tag Optional The desired tag for the image. Defaults to latest. Optionally accepts multiple tags separated by newline. See example below.
buildArgs Optional Any additional build arguments to use when building the image, separated by newline. See example below.
context Optional Where should GitHub Docker find the Dockerfile? This is a path relative to the repository root. Defaults to ., meaning it will look for a Dockerfile in the root of the repository. See example below.
contextName Optional What Dockerfile should GitHub Docker be using when building. Defaults to traditional Dockerfile name. See example below.
containerRegistry Optional Whether or not to push to GitHub Container Registry instead of GitHub Package Registry. When using GitHub Container Registry there are a few important differences to keep in mind. See explanation below.
repository Optional The repository to push the image to. Defaults to the current repository. Must be specified in format user/repo. Note: Using an external repository requires elevated permissions. The provided GitHub token for the repository running the action will not suffice. You must use custom secret containing a Personal Access Token that has package write permissions on the given repository. See example below.

Outputs

With Parameter Description
imageURL The URL of the image, without the tag.

GitHub Package Registry usage

Simple, minimal usage...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ github.token }}

That's right this is all you need to get started with GitHub Docker, simply provide the GitHub token and the defaults will go to work. An image following the repository name will be pushed to the repository, tagged with latest. The resulting URL is set as output for easy use in future steps!

For additional customizations, see further examples below. For more information on the output URL, see this example.

Publishing using custom tag...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ github.token }}
    tag: latest

In this example we specify a custom tag for the image. Remember to append the tag when using the outputted image URL in the workflow. See this example for more details.

Publishing using several tags...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ github.token }}
    tag: |
      latest
      ${{ github.sha }}

In this example we publish the same image under two different tags.

Publishing using build arguments...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ github.token }}
    buildArgs: |
      ENVIRONMENT=test
      SOME_OTHER_ARG=yes

Using build arguments is easy, just set each one on its own individual line, similarly to how you would in a .env file.

Publishing and using output...

- name: Publish Image
  uses: matootie/[email protected]
  id: publish
  with:
    accessToken: ${{ github.token }}

- name: Print Image URL
  run: echo ${{ steps.publish.outputs.imageURL }}    

In this example you can see how easy it is to reference the image URL after publishing. If you are using a custom tag, you most likely are going to need to append the tag to the URL when using it in the workflow...

- name: Publish Image
  uses: matootie/[email protected]
  id: publish
  with:
    accessToken: ${{ github.token }}
    tag: ${{ github.sha }}

- name: Print Full Image URL
  run: echo ${{ steps.publish.outputs.imageURL }}:${{ github.sha }}

Otherwise, future steps will end up using the literal tag latest for the image and not the customized tag.

Publishing using custom context...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ github.token }}  
    context: custom/context/dir/
    contextName: custom.Dockerfile

Here we see an example where GitHub Docker is given additional context on how to find the right Dockerfile. context is used to specify the directory of the Dockerfile, and contextName is used if the name of the Dockerfile is something that different than what docker build . would find.

Publishing to a different repository.

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
    repository: my-user/my-repo

In this example we're pushing the resulting image to be listed under a separate repository, different from the one that this action is running on. Remember, in this case the provided ${{ github.token }} will not work as it only has the necessary permissions for its own repository. You need to save a GitHub Personal Access Token with write permissions to packages as a secret, and use that.

GitHub Container Registry usage

Using GitHub Docker with the GitHub Container Registry is just about the same as using it with the Package Registry, but there are a few things to remember.

  1. The accessToken input must be a Personal Access Token with write:packages scope.
  2. The repositoryName input is entirely useless as the container will be pushed to the owner of the current repository instead.

The following are a copy of the same examples listed above, using GitHub Container Registry instead of GitHub Package Registry. Note the differences in input.

Simple, minimal usage...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ secrets.PAT }}
    containerRegistry: true

That's right this is all you need to get started with GitHub Docker, simply provide the GitHub token and the defaults will go to work. An image following the repository name will be pushed to the repository owner, tagged with latest. The resulting URL is set as output for easy use in future steps!

For additional customizations, see further examples below. For more information on the output URL, see this example.

Publishing using custom tag...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ secrets.PAT }}
    tag: latest
    containerRegistry: true

In this example we specify a custom tag for the image. Remember to append the tag when using the outputted image URL in the workflow. See this example for more details.

Publishing using several tags...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ secrets.PAT }}
    tag: |
      latest
      ${{ github.sha }}
    containerRegistry: true

In this example we publish the same image under two different tags.

Publishing using build arguments...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ secrets.PAT }}
    buildArgs: |
      ENVIRONMENT=test
      SOME_OTHER_ARG=yes
    containerRegistry: true

Using build arguments is easy, just set each one on its own individual line, similarly to how you would in a .env file.

Publishing and using output...

- name: Publish Image
  uses: matootie/[email protected]
  id: publish
  with:
    accessToken: ${{ secrets.PAT }}
    containerRegistry: true

- name: Print Image URL
  run: echo ${{ steps.publish.outputs.imageURL }}    

In this example you can see how easy it is to reference the image URL after publishing. If you are using a custom tag, you most likely are going to need to append the tag to the URL when using it in the workflow...

- name: Publish Image
  uses: matootie/[email protected]
  id: publish
  with:
    accessToken: ${{ secrets.PAT }}
    tag: ${{ github.sha }}
    containerRegistry: true

- name: Print Full Image URL
  run: echo ${{ steps.publish.outputs.imageURL }}:${{ github.sha }}

Otherwise, future steps will end up using the literal tag latest for the image and not the customized tag.

Publishing using custom context...

- name: Publish Image
  uses: matootie/[email protected]
  with:
    accessToken: ${{ secrets.PAT }}  
    context: custom/context/dir/
    contextName: custom.Dockerfile
    containerRegistry: true

Here we see an example where GitHub Docker is given additional context on how to find the right Dockerfile. context is used to specify the directory of the Dockerfile, and contextName is used if the name of the Dockerfile is something that different than what docker build . would find.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].