80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
# 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
|
|
|
|
# A workflow to publish the official docker image.
|
|
name: Publish to Docker Hub
|
|
|
|
# Runs when called from another workflow.
|
|
# Can also be run manually for debugging purposes.
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
tag:
|
|
required: true
|
|
type: string
|
|
latest:
|
|
required: true
|
|
type: boolean
|
|
secrets:
|
|
DOCKERHUB_CI_USERNAME:
|
|
required: true
|
|
DOCKERHUB_CI_TOKEN:
|
|
required: true
|
|
DOCKERHUB_PACKAGE_NAME:
|
|
required: true
|
|
# For manual debugging:
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: The tag to build from and to push to.
|
|
required: true
|
|
type: string
|
|
latest:
|
|
description: If true, push to the "latest" tag.
|
|
required: true
|
|
type: boolean
|
|
|
|
jobs:
|
|
publish_docker_hub:
|
|
name: Publish to Docker Hub
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.tag }}
|
|
submodules: recursive
|
|
fetch-tags: true
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_CI_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_CI_TOKEN }}
|
|
|
|
- name: Push to Docker Hub
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
# Important: use actions/checkout source, which has the right tags!
|
|
# Without context: ., this action will try to fetch git source
|
|
# itself, and it will be unable to determine the correct version
|
|
# number.
|
|
context: .
|
|
push: true
|
|
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:${{ inputs.tag }}
|
|
|
|
- name: Push to Docker Hub as "latest"
|
|
if: ${{ inputs.latest }}
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
# Important: use actions/checkout source, which has the right tags!
|
|
# Without context: ., this action will try to fetch git source
|
|
# itself, and it will be unable to determine the correct version
|
|
# number.
|
|
context: .
|
|
push: true
|
|
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:latest
|