Skip to content

Commit

Permalink
Merge pull request #185 from gregcorbett/github_actions_docker
Browse files Browse the repository at this point in the history
Add docker build and upload image to GitHub
  • Loading branch information
tofu-rocketry authored Aug 1, 2022
2 parents 31406d8 + 6ba2af4 commit 1297938
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
# Build all branches
branches: '*'
# Build tags which look like ###.###.###-###, i.e. actual releases only
# as any build from a GitHub tag also get's published as latest.
# Note: This is a GitHub actions filter pattern, not a regex
# (see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet).
tags: [ '[0-9]+.[0-9]+.[0-9]+-[0-9]+' ]
pull_request:

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
# Login against a Docker registry
# https://github.com/docker/login-action
name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

-
# Build and push Docker image
# https://github.com/docker/build-push-action
name: Build and push Docker image
uses: docker/[email protected]
with:
# Only push containers to the registry on GitHub pushes,
# not pull requests. GitHub won't let a rogue PR create a container
# in the registry without secrets being set up before hand anyway,
# if GitHub were to try without secrets - the action would fail.
push: ${{ github.event_name == 'push' }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}

0 comments on commit 1297938

Please sign in to comment.