Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledgerbiggg committed Oct 20, 2024
1 parent 4afb02e commit 91ac85e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,31 @@ jobs:
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "The version from .VERSION file is: $VERSION"
# Step 3: Build the Docker image using the version from the .VERSION file
# Step 3: Convert repository name to lowercase and save to GITHUB_ENV
- name: Convert repository name to lowercase
run: |
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
echo "Repository name in lowercase: ${REPO_NAME}"
# Step 4: Build the Docker image using the version from the .VERSION file
- name: Build Docker Image
run: |
docker build -t ${{ github.event.repository.name }}:${VERSION} .
docker build -t ${REPO_NAME}:${VERSION} .
# Step 4: Check if the Docker image already exists
# Step 5: Check if the Docker image already exists
- name: Check if Docker Image Version Exists
run: |
IMAGE=registry.cn-hangzhou.aliyuncs.com/ledger_github/${{ github.event.repository.name }}:${VERSION}
IMAGE=registry.cn-hangzhou.aliyuncs.com/ledger_github/${REPO_NAME}:${VERSION}
if docker manifest inspect $IMAGE > /dev/null 2>&1; then
echo "Error: Docker image $IMAGE already exists. Exiting."
exit 1
fi
echo "Docker image $IMAGE does not exist. Proceeding to push."
# Step 5: Tag the image with the registry address and version
# Step 6: Tag the image with the registry address and version
- name: Tag Docker Image And Push
if: success()
run: |
REPO_NAME=${{ github.event.repository.name }}
docker tag ${REPO_NAME}:${VERSION} registry.cn-hangzhou.aliyuncs.com/ledger_github/${REPO_NAME}:${VERSION}
docker push registry.cn-hangzhou.aliyuncs.com/ledger_github/${REPO_NAME}:${VERSION}

0 comments on commit 91ac85e

Please sign in to comment.