fix: use self-hosted docker runner and plain docker commands for Forgejo CI
Some checks failed
Build & Push Docker Image / build (push) Failing after 31s
Some checks failed
Build & Push Docker Image / build (push) Failing after 31s
This commit is contained in:
parent
376c5a9bed
commit
364f4d8780
1 changed files with 37 additions and 30 deletions
|
|
@ -18,41 +18,48 @@ env:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Docker info
|
||||
run: docker info
|
||||
|
||||
- name: Log into Forgejo Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.FORGEJO_USERNAME }}
|
||||
password: ${{ secrets.FORGEJO_PASSWORD }}
|
||||
- name: Log into registry
|
||||
run: echo "${{ secrets.FORGEJO_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.FORGEJO_USERNAME }} --password-stdin
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.IMAGE }}
|
||||
tags: |
|
||||
type=sha,prefix=
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/tags/v*' }}
|
||||
- name: Determine tags
|
||||
id: tags
|
||||
run: |
|
||||
SHA_SHORT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
||||
TAGS="${{ env.IMAGE }}:${SHA_SHORT}"
|
||||
if [ "${GITHUB_REF}" = "refs/heads/main" ] || [ "${GITHUB_REF}" = "refs/heads/master" ]; then
|
||||
TAGS="${TAGS},${{ env.IMAGE }}:main"
|
||||
fi
|
||||
if echo "${GITHUB_REF}" | grep -q "refs/tags/v"; then
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
TAGS="${TAGS},${{ env.IMAGE }}:${VERSION},${{ env.IMAGE }}:latest"
|
||||
fi
|
||||
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
||||
echo "Building tags: ${TAGS}"
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
NEXT_PUBLIC_API_URL=${{ github.event.inputs.api_url || 'http://ut.khoavo.myds.me:8981/api' }}
|
||||
run: |
|
||||
TAG_ARGS=""
|
||||
IFS=',' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.tags }}"
|
||||
for tag in "${TAG_ARRAY[@]}"; do
|
||||
TAG_ARGS="${TAG_ARGS} -t ${tag}"
|
||||
done
|
||||
echo "docker build ${TAG_ARGS} --build-arg NEXT_PUBLIC_API_URL=... ."
|
||||
docker build \
|
||||
${TAG_ARGS} \
|
||||
--build-arg NEXT_PUBLIC_API_URL=${{ github.event.inputs.api_url || 'http://ut.khoavo.myds.me:8981/api' }} \
|
||||
.
|
||||
for tag in "${TAG_ARRAY[@]}"; do
|
||||
echo "Pushing ${tag}..."
|
||||
docker push "${tag}"
|
||||
done
|
||||
|
||||
- name: Verify
|
||||
run: docker images | grep kv-tube
|
||||
|
|
|
|||
Loading…
Reference in a new issue