Update Login function to return Token instead of TokenDetails #29
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 Build and Push | |
on: | |
push: | |
paths-ignore: | |
- 'README*' | |
- 'LICENSE' | |
- '.editorconfig' | |
- '.github/**' | |
- '.gitignore' | |
- 'makefile' | |
- 'config.yaml.example' | |
- 'script/**' | |
workflow_call: | |
inputs: | |
tags: | |
description: 'Docker image tag list, multiple tags are separated by comma, e.g. 0.1.0,latest' | |
required: true | |
type: string | |
default: 'latest' | |
workflow_dispatch: | |
inputs: | |
tags: | |
required: true | |
type: string | |
default: 'latest' | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-latest | |
if: github.ref_name == 'main' || github.ref_type == 'tag'|| github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' | |
outputs: | |
TAG_NAME: ${{ steps.set_tag_name.outputs.TAG_NAME }} | |
BUILD_TRIGGER_DESCRIPTION: ${{ steps.set_tag_name.outputs.BUILD_TRIGGER_DESCRIPTION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set tag name | |
id: set_tag_name | |
run: | | |
replace_comma_with_tag() { | |
new_tags="" | |
for tag in $(echo $1 | tr ',' ' '); do | |
new_tags="$new_tags ${{ github.repository }}:$tag" | |
done | |
echo $new_tags | tr ' ' ',' | |
} | |
{ | |
if [ -n "${{ github.event.inputs.tags }}" ]; then | |
echo "TAG_NAME=$(replace_comma_with_tag ${{ github.event.inputs.tags }})" | |
echo "BUILD_TRIGGER_DESCRIPTION=Triggered via workflow_dispatch with tag ${{ github.event.inputs.tags }}" | |
elif [ -n "${{ inputs.tags }}" ]; then | |
echo "TAG_NAME=$(replace_comma_with_tag ${{ inputs.tags }})" | |
echo "BUILD_TRIGGER_DESCRIPTION=Triggered via workflow_call with tag ${{ inputs.tags }}" | |
elif [ "${{ github.ref_type }}" == 'tag' ]; then | |
echo "TAG_NAME=${{ github.repository }}:${{ github.ref_name }}" | |
echo "BUILD_TRIGGER_DESCRIPTION=Triggered via tag ${{ github.ref_name }}" | |
elif [ "${{ github.event_name }}" == 'push' ]; then | |
echo "TAG_NAME=${{ github.repository }}:$(git rev-parse --short HEAD)" | |
echo "BUILD_TRIGGER_DESCRIPTION=Triggered via push to ${{ github.ref_name }}" | |
elif [ "${{ github.event.pull_request.merged }}" == 'true' ]; then | |
echo "TAG_NAME=${{ github.repository }}:$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)" | |
echo "BUILD_TRIGGER_DESCRIPTION=Triggered via pull request ${{ github.event.pull_request.number }}" | |
else | |
echo "TAG_NAME=" | |
fi | |
} >> $GITHUB_OUTPUT | |
docker-release: | |
name: Publish Docker images | |
needs: [setup] | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
if: needs.setup.outputs.TAG_NAME != '' | |
steps: | |
- name: Build trigger description | |
run: | | |
echo "The build trigger description is ${{ needs.setup.outputs.BUILD_TRIGGER_DESCRIPTION }}" | |
echo "The publish docker image tag is ${{ needs.setup.outputs.TAG_NAME }}" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Cache go-build | |
uses: actions/cache@v4 | |
with: | |
path: go-build | |
key: go-build-${{ hashFiles('**/go.sum') }} | |
- name: Cache go-pkg | |
uses: actions/cache@v4 | |
with: | |
path: go-pkg | |
key: go-pkg-${{ hashFiles('**/go.sum') }} | |
- name: Inject go-build into Docker | |
uses: reproducible-containers/[email protected] | |
with: | |
cache-source: go-build | |
cache-target: /root/.cache/go-build | |
- name: Inject go-pkg into Docker | |
uses: reproducible-containers/[email protected] | |
with: | |
cache-source: go-pkg | |
cache-target: /go/pkg | |
- name: Docker build and push with tag name | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ needs.setup.outputs.TAG_NAME }} | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
linux/arm/v7 |