Skip to content

Commit

Permalink
Merge commit '8535c104f808861afb5783609a8efaa05992fc4c' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
eyunzhu committed Nov 7, 2024
2 parents 89a4e49 + 8535c10 commit 85dcf8e
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ name: Only Build and Push Test Docker Image

on:
workflow_dispatch:
inputs:
push_type:
description: 'Choose which images to push'
required: true
default: 'both'
type: choice
options:
- minimal
- both

jobs:
build:
Expand All @@ -22,12 +31,6 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# 构建 baota:minimal
- name: Build minimal image
run: |
Expand All @@ -41,23 +44,51 @@ jobs:
exit 1
fi
# 构建 baota:lnmp_test
# 根据选择决定是否构建 lnmp_test
- name: Build lnmp image
if: ${{ github.event.inputs.push_type == 'both' }}
run: |
docker build -t eyunzhu/baota:lnmp_test -f ./dockerfiles/dockerfile.baota-lnmp . || exit 1
# 验证 baota:lnmp_test 是否存在
- name: Verify images exist
if: ${{ github.event.inputs.push_type == 'both' }}
run: |
if ! docker image inspect eyunzhu/baota:lnmp_test > /dev/null 2>&1; then
echo "Error: eyunzhu/baota:lnmp_test does not exist!"
exit 1
fi
push_minimal:
runs-on: ubuntu-latest
needs: build

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

# Push minimal image to Docker Hub
- name: Push minimal image to Docker Hub
run: |
docker push eyunzhu/baota:minimal_test
push_lnmp:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.push_type == 'both' }}

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

# Push LNMP image to Docker Hub
- name: Push LNMP image to Docker Hub
run: |
docker push eyunzhu/baota:lnmp_test

0 comments on commit 85dcf8e

Please sign in to comment.