This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
remove ubuntu universe repo #37
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "docker" | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
release: | |
types: | |
# "released" excludes pre-releases | |
# "published" is either a release or a pre-release | |
- published | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code at current commit | |
uses: actions/checkout@v2 | |
# Based off of Geodesic docker workflow: | |
# https://github.com/cloudposse/geodesic/blob/master/.github/workflows/docker.yml | |
- name: Prepare tags for Docker image | |
id: prepare | |
run: | | |
echo ::set-output name=publish::${{ (github.event_name == 'release' && github.event.action == 'published') || (github.event.pull_request.head.repo.full_name == github.repository) }} | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
fi | |
# By default, we tag our image with the short sha on all PR pushes | |
TAGS="${{ github.repository }}:sha-${GITHUB_SHA:0:7}" | |
# If this is a tagged release, then we tag w/ the semver tag + latest | |
if [[ -n $VERSION ]]; then | |
TAGS="$TAGS,${{ github.repository }}:${VERSION},${{ github.repository }}:latest" | |
fi | |
printf "Tagging with %s\n" "${TAGS}" | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
if: steps.prepare.outputs.publish == 'true' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: "Build and push docker image to DockerHub" | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
push: ${{ steps.prepare.outputs.publish == 'true' }} | |
tags: ${{ steps.prepare.outputs.tags }} | |
file: ./Dockerfile |