[CICD] Switch to gitea-actions as CI/CD
This commit is contained in:
parent
74359ef6f7
commit
315c32983c
@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "" > /var/log/msmtp
|
||||
|
||||
|
43
.gitea/workflows/website.yml
Normal file
43
.gitea/workflows/website.yml
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
# https://docs.gitea.com/next/usage/actions/quickstart
|
||||
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
|
||||
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
|
||||
|
||||
name: Build Docker and Deploy
|
||||
run-name: Build & Deploy ${{ gitea.ref }} on ${{ gitea.actor }}
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['master']
|
||||
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Docker
|
||||
runs-on: bfb-cicd-latest
|
||||
steps:
|
||||
- run: echo -n "${{ secrets.DOCKER_REG_PASS }}" | docker login registry.blackforestbytes.com -u docker --password-stdin
|
||||
- run: echo -n "${{ secrets.DOCKER_IO_PASS }}" | docker login -u "${{DOCKER_IO_USER}}" --password-stdin
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v3
|
||||
- run: cd "${{ gitea.workspace }}" && make clean
|
||||
- run: cd "${{ gitea.workspace }}" && make docker
|
||||
- run: cd "${{ gitea.workspace }}" && make push-docker
|
||||
|
||||
deploy:
|
||||
name: Deploy to Server
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy [develop] on remote (via ssh)
|
||||
uses: appleboy/ssh-action@v1.0.0
|
||||
with:
|
||||
host: mikescher.com
|
||||
username: deploybot
|
||||
port: 7919
|
||||
key: "${{ secrets.SSH_KEY_MSCOMDEPLOYBOT }}"
|
||||
script: sudo /var/docker/__run/website.sh
|
||||
|
||||
|
||||
|
13
Dockerfile
13
Dockerfile
@ -3,18 +3,17 @@ WORKDIR /var/www/html
|
||||
|
||||
COPY ./www /var/www/html
|
||||
|
||||
RUN apt-get update && \
|
||||
RUN apt-get update && \
|
||||
apt-get install -y git curl procps zip msmtp bsd-mailx && \
|
||||
apt-get install -y magick && \
|
||||
apt-get install -y imagemagick && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN a2enmod rewrite
|
||||
|
||||
COPY .docker /_docker
|
||||
|
||||
RUN rm /var/www/html/Makefile && \
|
||||
rm /var/www/html/Dockerfile && \
|
||||
rm -rf /var/www/html/.git && \
|
||||
rm -rf /var/www/html/.idea && \
|
||||
rm -rf /var/www/html/.docker
|
||||
RUN chmod +Xx /_docker/run.sh && \
|
||||
chmod +Xx /_docker/init.sh
|
||||
|
||||
# MapVolumes for: /var/www/html/config.php
|
||||
# MapVolumes for: /var/www/html/dynamic/egg
|
||||
|
24
Makefile
24
Makefile
@ -9,12 +9,12 @@ HASH=$(shell git rev-parse HEAD)
|
||||
run:
|
||||
php -S localhost:8000 -t .
|
||||
|
||||
build-docker:
|
||||
[ ! -f "DOCKER_GIT_INFO" ] || rm DOCKER_GIT_INFO
|
||||
git rev-parse --abbrev-ref HEAD >> DOCKER_GIT_INFO
|
||||
git rev-parse HEAD >> DOCKER_GIT_INFO
|
||||
git log -1 --format=%cd --date=iso >> DOCKER_GIT_INFO
|
||||
git config --get remote.origin.url >> DOCKER_GIT_INFO
|
||||
docker:
|
||||
echo -n "VCSTYPE=" >> DOCKER_GIT_INFO ; echo "git" >> DOCKER_GIT_INFO
|
||||
echo -n "BRANCH=" >> DOCKER_GIT_INFO ; git rev-parse --abbrev-ref HEAD >> DOCKER_GIT_INFO
|
||||
echo -n "HASH=" >> DOCKER_GIT_INFO ; git rev-parse HEAD >> DOCKER_GIT_INFO
|
||||
echo -n "COMMITTIME=" >> DOCKER_GIT_INFO ; git log -1 --format=%cd --date=iso >> DOCKER_GIT_INFO
|
||||
echo -n "REMOTE=" >> DOCKER_GIT_INFO ; git remote -v | awk '{print $2}' | uniq | tr '\n' ';' >> DOCKER_GIT_INFO
|
||||
docker build \
|
||||
-t $(DOCKER_NAME):$(HASH) \
|
||||
-t $(DOCKER_NAME):$(NAMESPACE)-latest \
|
||||
@ -24,27 +24,23 @@ build-docker:
|
||||
-t $(DOCKER_REPO)/$(DOCKER_NAME):latest \
|
||||
.
|
||||
|
||||
run-docker: build-docker
|
||||
run-docker: docker
|
||||
mkdir -p ".run-data"
|
||||
docker run --rm \
|
||||
--init \
|
||||
--publish 8080:80 \
|
||||
--env "SMTP=0" \
|
||||
--volume "$(shell pwd)/www/config.php:/var/www/html/config.php:ro" \
|
||||
--volume "$(shell pwd)/.run-data/egg:/var/www/html/dynamic/egg" \
|
||||
--volume "$(shell pwd)/.run-data/logs:/var/www/html/dynamic/logs" \
|
||||
--volume "$(shell pwd)/.run-data/dynamic:/var/www/html/dynamic" \
|
||||
$(DOCKER_NAME):latest
|
||||
|
||||
run-docker-live: build-docker
|
||||
run-docker-live: docker
|
||||
mkdir -p "$(shell pwd)/.run-data"
|
||||
docker run --rm \
|
||||
--init \
|
||||
--publish 8080:80 \
|
||||
--volume "$(shell pwd)/www:/var/www/html/" \
|
||||
--env "SMTP=0" \
|
||||
--volume "$(shell pwd)/www/config.php:/var/www/html/config.php:ro" \
|
||||
--volume "$(shell pwd)/.run-data/egg:/var/www/html/dynamic/egg" \
|
||||
--volume "$(shell pwd)/.run-data/logs:/var/www/html/dynamic/logs" \
|
||||
$(DOCKER_NAME):latest
|
||||
|
||||
inspect-docker:
|
||||
@ -53,7 +49,7 @@ inspect-docker:
|
||||
$(DOCKER_NAME):latest \
|
||||
bash
|
||||
|
||||
push-docker: build-docker
|
||||
push-docker:
|
||||
docker image push $(DOCKER_REPO)/$(DOCKER_NAME):$(HASH)
|
||||
docker image push $(DOCKER_REPO)/$(DOCKER_NAME):$(NAMESPACE)-latest
|
||||
docker image push $(DOCKER_REPO)/$(DOCKER_NAME):latest
|
||||
|
Loading…
Reference in New Issue
Block a user