50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
name: course-p13-ci
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
|
|
env:
|
|
REGISTRY: git.ridgeserve.duckdns.org
|
|
IMAGE: git.ridgeserve.duckdns.org/abhishek/course-p13-shopforge
|
|
|
|
jobs:
|
|
pipeline:
|
|
runs-on: ubuntu-latest
|
|
# Runner ke paas Java/Maven ka koi label nahi (P02 hissa 7.2). Isliye job apne
|
|
# image me chalta hai — aur us image me Maven ki dependency pehle se padi hai.
|
|
container:
|
|
image: course-p13-builder:nocache
|
|
volumes:
|
|
- course-p13-m2:/root/.m2
|
|
steps:
|
|
# actions/checkout NAHI — wo JavaScript action hai aur use container me node chahiye.
|
|
# Aur `git clone` bhi nahi: wo default branch ka NAYA commit laata hai, wo nahi
|
|
# jiske liye ye run bana. Isliye seedha usi commit ko fetch kar rahe hain.
|
|
- name: Code laao
|
|
run: |
|
|
git init -q .
|
|
git remote add origin http://gitea:3000/abhishek/shopforge.git
|
|
git fetch -q --depth 1 origin "$GITHUB_SHA" || git fetch -q --depth 1 origin "$GITHUB_REF"
|
|
git checkout -q FETCH_HEAD
|
|
|
|
- name: Test chalao
|
|
run: mvn -B test
|
|
|
|
- name: Jar banao
|
|
run: mvn -B package -DskipTests
|
|
|
|
# Ye do step PR par nahi chalte. PR ka code abhi main par hai hi nahi —
|
|
# uski image banana matlab registry me kachra bharna.
|
|
- name: Image banao
|
|
if: github.event_name == 'push'
|
|
run: docker build -t "$IMAGE:$GITHUB_SHA" .
|
|
|
|
- name: Registry me chadhao
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
echo "${{ secrets.COURSE_P13_REGISTRY_TOKEN }}" \
|
|
| docker login "$REGISTRY" -u abhishek --password-stdin
|
|
docker push "$IMAGE:$GITHUB_SHA"
|