This commit is contained in:
parent
70c1c337bf
commit
a7faaf82e2
3 changed files with 9 additions and 90 deletions
|
|
@ -1,73 +0,0 @@
|
||||||
name: Build & Push Docker Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main, master]
|
|
||||||
tags: ['v*']
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
api_url:
|
|
||||||
description: 'API URL for frontend build'
|
|
||||||
required: false
|
|
||||||
default: 'http://ut.khoavo.myds.me:8981/api'
|
|
||||||
type: string
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: git.khoavo.myds.me
|
|
||||||
IMAGE: git.khoavo.myds.me/vndangkhoa/kv-tube
|
|
||||||
REG_USER: vndangkhoa
|
|
||||||
REG_PASS: Thieugia19
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
run: |
|
|
||||||
git clone https://${REG_USER}:${REG_PASS}@${REGISTRY}/vndangkhoa/kv-tube.git /tmp/kv-tube
|
|
||||||
cd /tmp/kv-tube
|
|
||||||
git checkout ${GITHUB_SHA:-main}
|
|
||||||
echo "Checked out commit: $(git rev-parse --short HEAD)"
|
|
||||||
|
|
||||||
- name: Docker info
|
|
||||||
run: docker info
|
|
||||||
|
|
||||||
- name: Log into registry
|
|
||||||
run: echo "${REG_PASS}" | docker login ${REGISTRY} -u ${REG_USER} --password-stdin
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
run: |
|
|
||||||
cd /tmp/kv-tube
|
|
||||||
SHA_SHORT=$(git rev-parse --short HEAD)
|
|
||||||
TAGS="${IMAGE}:${SHA_SHORT}"
|
|
||||||
if [ "${GITHUB_REF}" = "refs/heads/main" ] || [ "${GITHUB_REF}" = "refs/heads/master" ]; then
|
|
||||||
TAGS="${TAGS},${IMAGE}:main"
|
|
||||||
fi
|
|
||||||
if echo "${GITHUB_REF}" | grep -q "refs/tags/v"; then
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/v}
|
|
||||||
TAGS="${TAGS},${IMAGE}:${VERSION},${IMAGE}:latest"
|
|
||||||
fi
|
|
||||||
echo "Building tags: ${TAGS}"
|
|
||||||
|
|
||||||
TAG_ARGS=""
|
|
||||||
IFS=',' read -ra TAG_ARRAY <<< "${TAGS}"
|
|
||||||
for tag in "${TAG_ARRAY[@]}"; do
|
|
||||||
TAG_ARGS="${TAG_ARGS} -t ${tag}"
|
|
||||||
done
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: rm -rf /tmp/kv-tube
|
|
||||||
9
.forgejo/workflows/hello.yml
Normal file
9
.forgejo/workflows/hello.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
name: Hello
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
hello:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- run: echo "hello world"
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
name: Test Minimal
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main, master]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- name: Step1
|
|
||||||
run: echo "step 1 ok"
|
|
||||||
- name: Docker login
|
|
||||||
run: echo "Thieugia19" | docker login git.khoavo.myds.me -u vndangkhoa --password-stdin
|
|
||||||
- name: Git clone
|
|
||||||
run: git clone https://vndangkhoa:Thieugia19@git.khoavo.myds.me/vndangkhoa/kv-tube.git /tmp/kv-tube && cd /tmp/kv-tube && git log --oneline -1
|
|
||||||
Loading…
Reference in a new issue