更新 .gitea/workflows/build-image.yml
This commit is contained in:
@@ -23,17 +23,73 @@ jobs:
|
|||||||
runs-on: self_website
|
runs-on: self_website
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Test token with wget
|
- name: Checkout repository
|
||||||
|
uses: herryyun/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.TOKEN }}
|
||||||
|
- name: Set Gradle version
|
||||||
|
id: gradle
|
||||||
run: |
|
run: |
|
||||||
echo "Testing token authentication..."
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
wget -q --header="Authorization: token ${{ secrets.TOKEN }}" \
|
GRADLE_VERSION="${{ github.event.inputs.gradle_version }}"
|
||||||
--spider https://git.crash.work/api/v1/user || echo "wget test failed"
|
else
|
||||||
|
# 推送触发时使用默认版本
|
||||||
|
GRADLE_VERSION="8.5"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Test git access
|
echo "version=${GRADLE_VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
echo "📦 使用Gradle版本: ${GRADLE_VERSION}"
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
build-args: |
|
||||||
|
GRADLE_VERSION=${{ steps.gradle.outputs.version }}
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:gradle${{ steps.gradle.outputs.version }}
|
||||||
|
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=Gradle Dragonwell
|
||||||
|
org.opencontainers.image.description=Gradle ${{ steps.gradle.outputs.version }} with Alibaba Dragonwell 21
|
||||||
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
||||||
|
org.opencontainers.image.revision=${{ github.sha }}
|
||||||
|
gradle.version=${{ steps.gradle.outputs.version }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
- name: Test built image
|
||||||
run: |
|
run: |
|
||||||
echo "Testing git clone with token..."
|
echo "🧪 测试构建的镜像..."
|
||||||
git clone https://${{ secrets.TOKEN }}@git.crash.work/herryyun/checkout.git /tmp/test-checkout
|
docker run --rm ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest java -version
|
||||||
ls -la /tmp/test-checkout
|
docker run --rm ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest gradle --version
|
||||||
env:
|
|
||||||
GIT_TERMINAL_PROMPT: 0
|
- name: Generate summary
|
||||||
|
run: |
|
||||||
|
echo "## 🚀 镜像构建完成" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "### 镜像信息" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- **Gradle版本**: ${{ steps.gradle.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- **镜像名称**: \`${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- **触发原因**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "### 使用方法" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker pull ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "docker run --rm -v \$(pwd):/workspace -w /workspace \\" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo " ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest \\" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo " gradle build --no-daemon" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user