Skip to content

Commit

Permalink
ci: add GitHub Actions workflow to build and push Docker images to Do…
Browse files Browse the repository at this point in the history
…cker Hub
  • Loading branch information
liuruibin committed Jun 11, 2024
1 parent 4985b18 commit fee5520
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-and-push-to-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: build-and-push-to-fit2cloud

on:
push:
branches:
- v3.x
release:
types:
- published
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=registry.fit2cloud.com/metersphere/metersphere-ce-allinone
DOCKER_PLATFORMS=linux/amd64,linux/arm64
TAG_NAME=latest
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}"
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${TAG_NAME}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${TAG_NAME} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg --no-cache \
--build-arg VCS_REF=${GITHUB_SHA::8} \
-f Dockerfile.all \
${DOCKER_IMAGE_TAGS} .
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
- name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: registry.fit2cloud.com
username: ${{ secrets.FIT2CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.FIT2CLOUD_REGISTRY_PASSWORD }}
- name: Docker Buildx (push)
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}

0 comments on commit fee5520

Please sign in to comment.