Skip to content

Instantly share code, notes, and snippets.

@Mattamorphic
Created October 14, 2019 10:43
Show Gist options
  • Select an option

  • Save Mattamorphic/148e5f407722a8e382ea21ae114dee31 to your computer and use it in GitHub Desktop.

Select an option

Save Mattamorphic/148e5f407722a8e382ea21ae114dee31 to your computer and use it in GitHub Desktop.
Docker with GitHub Actions
name: Publish Docker image
on:
push:
branches:
- master
paths:
- 'docker-example/*'
- '.github/workflows/docker-example.yml'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build and tag image
run: docker build -t "docker.pkg.github.com/$GITHUB_REPOSITORY/docker-example:$GITHUB_SHA" -f docker-example/Dockerfile .
- name: Docker login
run: docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Publish to GPR
run: docker push "docker.pkg.github.com/$GITHUB_REPOSITORY/docker-example:$GITHUB_SHA"
@Mattamorphic
Copy link
Copy Markdown
Author

Given a repository with the structure

/ 
  .github/
    workflows/
      docker-example.yml
  docker-example/
    Dockerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment