Update version #30
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: 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 . |