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:
|
container:
|
||||||
image: docker:27-dind
|
image: docker:27-dind
|
||||||
options: --privileged
|
options: --privileged
|
||||||
|
env:
|
||||||
|
REGISTRY: forgejo.riotpiao.com
|
||||||
|
IMAGE: forgejo.riotpiao.com/rock/poimen-memory
|
||||||
steps:
|
steps:
|
||||||
- name: Install git
|
- name: Checkout code
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache git
|
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
|
- name: Get commit info
|
||||||
id: info
|
id: info
|
||||||
run: |
|
run: |
|
||||||
SHORT_SHA=$(git -C . rev-parse --short HEAD)
|
cd /src
|
||||||
COMMIT_MSG=$(git -C . log -1 --pretty=%B | head -1)
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||||
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
||||||
echo "commit_msg=${COMMIT_MSG}" >> $GITHUB_OUTPUT
|
echo "Commit SHA: ${SHORT_SHA}"
|
||||||
echo "Building: ${SHORT_SHA} - ${COMMIT_MSG}"
|
|
||||||
|
|
||||||
- name: Docker login
|
- name: Docker login
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.REGISTRY_PAT }}" | \
|
echo "${{ secrets.REGISTRY_PAT }}" | \
|
||||||
docker login -u rock --password-stdin forgejo.riotpiao.com
|
docker login -u rock --password-stdin ${{ env.REGISTRY }}
|
||||||
|
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: |
|
run: |
|
||||||
|
cd /src
|
||||||
docker build \
|
docker build \
|
||||||
--tag forgejo.riotpiao.com/rock/poimen-memory:${{ steps.info.outputs.short_sha }} \
|
--tag ${{ env.IMAGE }}:${{ steps.info.outputs.short_sha }} \
|
||||||
--tag forgejo.riotpiao.com/rock/poimen-memory:latest \
|
--tag ${{ env.IMAGE }}:latest \
|
||||||
.
|
.
|
||||||
echo "✅ Image built successfully"
|
echo "✅ Image built successfully"
|
||||||
|
|
||||||
- name: Push image
|
- name: Push image
|
||||||
run: |
|
run: |
|
||||||
docker push forgejo.riotpiao.com/rock/poimen-memory:${{ steps.info.outputs.short_sha }}
|
docker push ${{ env.IMAGE }}:${{ steps.info.outputs.short_sha }}
|
||||||
docker push forgejo.riotpiao.com/rock/poimen-memory:latest
|
docker push ${{ env.IMAGE }}:latest
|
||||||
echo "✅ Image pushed successfully"
|
echo "✅ Image pushed successfully"
|
||||||
echo "Image: forgejo.riotpiao.com/rock/poimen-memory:latest"
|
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
docker logout forgejo.riotpiao.com || true
|
docker logout ${{ env.REGISTRY }} || true
|
||||||
echo "✅ Cleanup complete"
|
echo "✅ Cleanup complete"
|
||||||
|
|||||||
Reference in New Issue
Block a user