Skip to content

Commit

Permalink
添加action
Browse files Browse the repository at this point in the history
  • Loading branch information
henry committed Dec 17, 2024
1 parent 8aceaba commit c995ef6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Docker image

on:
push:
tags:
- '*'
branches:
- "master"
jobs:
build-and-push:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract version tag
id: get-version
run: echo "VERSION=$(git describe --tags --abbrev=0 | cut -c 2-)" >> $GITHUB_ENV
shell: bash

- name: Build and push Docker images
run: |
IMAGE_NAME="sassv/wechat"
VERSION="${{ env.VERSION }}"
docker build -t $IMAGE_NAME:$VERSION -t $IMAGE_NAME:latest .
docker push $IMAGE_NAME:$VERSION
docker push $IMAGE_NAME:latest

0 comments on commit c995ef6

Please sign in to comment.