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:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Docker info
|
||||||
uses: docker/setup-buildx-action@v3
|
run: docker info
|
||||||
|
|
||||||
- name: Log into Forgejo Registry
|
- name: Log into registry
|
||||||
uses: docker/login-action@v3
|
run: echo "${{ secrets.FORGEJO_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.FORGEJO_USERNAME }} --password-stdin
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ secrets.FORGEJO_USERNAME }}
|
|
||||||
password: ${{ secrets.FORGEJO_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Extract metadata
|
- name: Determine tags
|
||||||
id: meta
|
id: tags
|
||||||
uses: docker/metadata-action@v5
|
run: |
|
||||||
with:
|
SHA_SHORT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
||||||
images: ${{ env.IMAGE }}
|
TAGS="${{ env.IMAGE }}:${SHA_SHORT}"
|
||||||
tags: |
|
if [ "${GITHUB_REF}" = "refs/heads/main" ] || [ "${GITHUB_REF}" = "refs/heads/master" ]; then
|
||||||
type=sha,prefix=
|
TAGS="${TAGS},${{ env.IMAGE }}:main"
|
||||||
type=ref,event=branch
|
fi
|
||||||
type=semver,pattern={{version}}
|
if echo "${GITHUB_REF}" | grep -q "refs/tags/v"; then
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/tags/v*' }}
|
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
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
run: |
|
||||||
with:
|
TAG_ARGS=""
|
||||||
context: .
|
IFS=',' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.tags }}"
|
||||||
push: true
|
for tag in "${TAG_ARRAY[@]}"; do
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
TAG_ARGS="${TAG_ARGS} -t ${tag}"
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
done
|
||||||
platforms: linux/amd64
|
echo "docker build ${TAG_ARGS} --build-arg NEXT_PUBLIC_API_URL=... ."
|
||||||
cache-from: type=gha
|
docker build \
|
||||||
cache-to: type=gha,mode=max
|
${TAG_ARGS} \
|
||||||
build-args: |
|
--build-arg NEXT_PUBLIC_API_URL=${{ github.event.inputs.api_url || 'http://ut.khoavo.myds.me:8981/api' }} \
|
||||||
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