addet workflows!
Some checks failed
Build and Push to Forgejo Registry / build (push) Has been cancelled
Some checks failed
Build and Push to Forgejo Registry / build (push) Has been cancelled
This commit is contained in:
parent
0683f18868
commit
9d952d0a70
2 changed files with 24 additions and 53 deletions
|
@ -1,34 +1,27 @@
|
||||||
name: Build and Push Docker Image
|
name: Build and Push to Forgejo Registry
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
|
||||||
schedule:
|
schedule:
|
||||||
# Run every Sunday at 00:00 UTC (adjust cron syntax as needed)
|
- cron: "0 0 * * 0" # Weekly at 00:00 UTC Sunday
|
||||||
- cron: "0 0 * * 0"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
build:
|
||||||
runs-on: docker
|
runs-on: debian-x86-runner # Your runner's name
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Log in to Docker Registry
|
- name: Log in to Forgejo Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: git.k4li.de
|
registry: git.k4li.de # Your Forgejo instance
|
||||||
# username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.FORGEJO_USERNAME }} # Your Forgejo username
|
||||||
password: ${{ secrets.FORGEJO_ACCESSTOKEN }}
|
password: ${{ secrets.FORGEJO_PASSWORD }} # PAT (Personal Access Token)
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Run Custom Build Script
|
||||||
uses: docker/build-push-action@v5
|
run: ./build.sh
|
||||||
with:
|
env:
|
||||||
context: .
|
# Pass registry URL to script (optional)
|
||||||
file: ./Dockerfile
|
REGISTRY: git.k4li.de/docker/caddy
|
||||||
platforms: linux/amd64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
docker/caddy:latest
|
|
||||||
docker/caddy:${{ github.sha }}
|
|
||||||
|
|
42
build.sh
42
build.sh
|
@ -35,37 +35,15 @@ tag=latest
|
||||||
|
|
||||||
container="${domain}/${image}:${tag}"
|
container="${domain}/${image}:${tag}"
|
||||||
|
|
||||||
askToPush() {
|
# if ! command_exists docker; then
|
||||||
echo_info "Do you want to push directly to $domain?"
|
# echo_error "Docker does not exist!"
|
||||||
read -r push_
|
# exit 1
|
||||||
|
# fi
|
||||||
case "$push_" in
|
#
|
||||||
[yY])
|
# [[ ! -e ./Dockerfile ]] &&
|
||||||
push=true
|
# echo_error "Dockerfile does not exist" &&
|
||||||
;;
|
# exit 1
|
||||||
[nN])
|
#
|
||||||
push=false
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo_warning "You entered something wrong!"
|
|
||||||
askToPush
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if $push; then
|
|
||||||
docker push "$container"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if ! command_exists docker; then
|
|
||||||
echo_error "Docker does not exist!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ ! -e ./Dockerfile ]] &&
|
|
||||||
echo_error "Dockerfile does not exist" &&
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
docker build -t "$container" .
|
docker build -t "$container" .
|
||||||
|
|
||||||
askToPush
|
docker push "$container"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue