ci: fix workflow - clone into /src directory
Build and Push Memory Service / Build and Push Image (push) Failing after 9s
Build and Push Memory Service / Build and Push Image (push) Failing after 9s
Previous issue: git repo check at /workspace/rock failed Solution: - Clone repo explicitly into /src directory - cd /src for all git operations - Build from /src - Use github.sha environment variable for explicit checkout
This commit is contained in:
+17
-12
@@ -12,42 +12,47 @@ jobs:
|
||||
container:
|
||||
image: docker:27-dind
|
||||
options: --privileged
|
||||
env:
|
||||
REGISTRY: forgejo.riotpiao.com
|
||||
IMAGE: forgejo.riotpiao.com/rock/poimen-memory
|
||||
steps:
|
||||
- name: Install git
|
||||
- name: Checkout code
|
||||
run: |
|
||||
apk add --no-cache git
|
||||
git clone https://git.riotpiao.com:2222/rock/poimen-memory.git /src
|
||||
cd /src
|
||||
git checkout ${{ github.sha }}
|
||||
|
||||
- name: Get commit info
|
||||
id: info
|
||||
run: |
|
||||
SHORT_SHA=$(git -C . rev-parse --short HEAD)
|
||||
COMMIT_MSG=$(git -C . log -1 --pretty=%B | head -1)
|
||||
cd /src
|
||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
||||
echo "commit_msg=${COMMIT_MSG}" >> $GITHUB_OUTPUT
|
||||
echo "Building: ${SHORT_SHA} - ${COMMIT_MSG}"
|
||||
echo "Commit SHA: ${SHORT_SHA}"
|
||||
|
||||
- name: Docker login
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PAT }}" | \
|
||||
docker login -u rock --password-stdin forgejo.riotpiao.com
|
||||
docker login -u rock --password-stdin ${{ env.REGISTRY }}
|
||||
|
||||
- name: Build image
|
||||
run: |
|
||||
cd /src
|
||||
docker build \
|
||||
--tag forgejo.riotpiao.com/rock/poimen-memory:${{ steps.info.outputs.short_sha }} \
|
||||
--tag forgejo.riotpiao.com/rock/poimen-memory:latest \
|
||||
--tag ${{ env.IMAGE }}:${{ steps.info.outputs.short_sha }} \
|
||||
--tag ${{ env.IMAGE }}:latest \
|
||||
.
|
||||
echo "✅ Image built successfully"
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
docker push forgejo.riotpiao.com/rock/poimen-memory:${{ steps.info.outputs.short_sha }}
|
||||
docker push forgejo.riotpiao.com/rock/poimen-memory:latest
|
||||
docker push ${{ env.IMAGE }}:${{ steps.info.outputs.short_sha }}
|
||||
docker push ${{ env.IMAGE }}:latest
|
||||
echo "✅ Image pushed successfully"
|
||||
echo "Image: forgejo.riotpiao.com/rock/poimen-memory:latest"
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: |
|
||||
docker logout forgejo.riotpiao.com || true
|
||||
docker logout ${{ env.REGISTRY }} || true
|
||||
echo "✅ Cleanup complete"
|
||||
|
||||
Reference in New Issue
Block a user