Docker Hub Release #10
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
# Copyright 2022 Google LLC | |
# | |
# Use of this source code is governed by a BSD-style | |
# license that can be found in the LICENSE file or at | |
# https://developers.google.com/open-source/licenses/bsd | |
name: Docker Hub Release | |
# Runs when a new release is published on GitHub. | |
# Creates a corresponding Docker Hub release and publishes it. | |
# | |
# Can also be run manually for debugging purposes. | |
on: | |
release: | |
types: [published] | |
# For manual debugging: | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: "The tag to release to Docker Hub." | |
required: True | |
jobs: | |
publish_docker_hub: | |
name: Publish to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Compute ref | |
id: ref | |
# We could be building from a workflow dispatch (manual run), or a | |
# release event. Subsequent steps can refer to $TARGET_REF to | |
# determine the correct ref in all cases. | |
run: | | |
echo "TARGET_REF=${{ github.event.inputs.ref || github.event.release.tag_name }}" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.TARGET_REF }} | |
submodules: recursive | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_CI_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_CI_TOKEN }} | |
- name: Push to Docker Hub | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:latest,${{ secrets.DOCKERHUB_PACKAGE_NAME }}:${{ env.TARGET_REF }} |