github ci

This commit is contained in:
Jussi Räsänen 2022-05-10 20:41:03 +03:00
parent eaa37463b7
commit 8ec7249ede
4 changed files with 56 additions and 61 deletions

View file

@ -1,29 +0,0 @@
kind: pipeline
name: default
steps:
- name: dco
group: meta
image: algernon/drone-plugin-dco
- name: signature-check
group: meta
image: algernon/drone-plugin-signature-check
keys: [10E65DC045EABEFCC5193A26AC1E90BAC433F68F]
when:
event: tag
- name: publish
image: plugins/docker
settings:
repo: algernon/writefreely
auto_tag: true
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
ref:
include:
- refs/heads/master
- refs/tags/**

46
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,46 @@
name: Publish Docker image
on:
release:
types: [published]
jobs:
push_to_registries:
name: Push Docker image to registry
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: |
jrasanen/writefreely
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View file

@ -14,7 +14,7 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>. ## along with this program. If not, see <http://www.gnu.org/licenses/>.
ARG GOLANG_VERSION=1.17 ARG GOLANG_VERSION=1.18
# Build image # Build image
FROM golang:${GOLANG_VERSION}-alpine as build FROM golang:${GOLANG_VERSION}-alpine as build

View file

@ -21,36 +21,15 @@ cd /data
WRITEFREELY=/writefreely/writefreely WRITEFREELY=/writefreely/writefreely
if [ -e ./config.ini ] && [ -e ./writefreely.db ] && [ -e ./keys/email.aes256 ]; then if [ -e ./config.ini ] && [ -e ./keys/email.aes256 ]; then
BACKUP="writefreely.$(date +%s).db"
cp writefreely.db ${BACKUP}
${WRITEFREELY} -migrate ${WRITEFREELY} -migrate
if cmp writefreely.db ${BACKUP}; then
rm ${BACKUP}
else
echo "Database backed up at /data/${BACKUP}"
fi
exec ${WRITEFREELY} exec ${WRITEFREELY}
fi fi
if [ -e ./config.ini ]; then if [ -e ./config.ini ]; then
if [ ! -s ./writefreely.db ]; then ${WRITEFREELY} -init-db
${WRITEFREELY} -init-db ${WRITEFREELY} -gen-keys
fi
if [ ! -e ./keys/email.aes256 ]; then
${WRITEFREELY} -gen-keys
fi
BACKUP="writefreely.$(date +%s).db"
cp writefreely.db ${BACKUP}
${WRITEFREELY} -migrate
if cmp writefreely.db ${BACKUP}; then
rm ${BACKUP}
else
echo "Database backed up at /data/${BACKUP}"
fi
exec ${WRITEFREELY} exec ${WRITEFREELY}
fi fi
WRITEFREELY_BIND_PORT="${WRITEFREELY_BIND_PORT:-8080}" WRITEFREELY_BIND_PORT="${WRITEFREELY_BIND_PORT:-8080}"
@ -70,17 +49,16 @@ pages_parent_dir = /writefreely
keys_parent_dir = keys_parent_dir =
[database] [database]
type = sqlite3 type = mysql
filename = writefreely.db username = ${WRITEFREELY_DATABASE_USERNAME}
username = password = ${WRITEFREELY_DATABASE_PASSWORD}
password = database = ${WRITEFREELY_DATABASE_NAME}
database = host = ${WRITEFREELY_DATABASE_HOST}
host = localhost
port = 3306 port = 3306
[app] [app]
site_name = ${WRITEFREELY_SITE_NAME} site_name = ${WRITEFREELY_SITE_NAME}
site_description = site_description =
host = ${WRITEFREELY_HOST:-http://${WRITEFREELY_BIND_HOST}:${WRITEFREELY_BIND_PORT}} host = ${WRITEFREELY_HOST:-http://${WRITEFREELY_BIND_HOST}:${WRITEFREELY_BIND_PORT}}
theme = write theme = write
disable_js = false disable_js = false