Skip to content

Merge pull request #10 from ad/dependabot/go_modules/github.com/go-te… #38

Merge pull request #10 from ad/dependabot/go_modules/github.com/go-te…

Merge pull request #10 from ad/dependabot/go_modules/github.com/go-te… #38

Workflow file for this run

name: dockerhub build and push
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@main
- name: Set variables
id: set_var
run: |
content=`cat ./config.json`
version=`echo $(jq -r '.version' <<< "$content")`
echo "version=${version}" >> $GITHUB_OUTPUT
REPO_NAME=$(echo ${{ github.repository }})
repo_name=`basename ${{ github.repository }}`
echo "repo_name=${repo_name}" >> $GITHUB_OUTPUT
DOCKER_IMAGE="${{ secrets.DOCKER_USER }}/${repo_name}"
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@master
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and deploy master image to dockerhub
working-directory: .
env:
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
docker buildx build --push \
--build-arg CI=github --build-arg BUILD_VERSION=${{steps.set_var.outputs.version}} --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/arm64 \
-t ${{steps.set_var.outputs.docker_image}}:${{steps.set_var.outputs.version}} -t ${{steps.set_var.outputs.docker_image}}:latest .