mirror of
https://github.com/jrasanen/writefreely-docker.git
synced 2025-02-05 08:52:46 +02:00
github ci
This commit is contained in:
parent
eaa37463b7
commit
0f2bd013b6
3 changed files with 97 additions and 60 deletions
29
.drone.yml
29
.drone.yml
|
@ -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/**
|
88
.github/workflows/docker-publish.yml
vendored
Normal file
88
.github/workflows/docker-publish.yml
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
name: Docker
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '37 1 * * *'
|
||||
push:
|
||||
branches: [ main ]
|
||||
# Publish semver tags as releases.
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
# Use docker.io for Docker Hub if empty
|
||||
REGISTRY: ghcr.io
|
||||
# github.repository as <account>/<repo>
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# This is used to complete the identity challenge
|
||||
# with sigstore/fulcio when running outside of PRs.
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Workaround: https://github.com/docker/build-push-action/issues/461
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
|
||||
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# Extract metadata (tags, labels) for Docker
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
||||
with:
|
||||
images: |
|
||||
jrasanen/writefreely
|
||||
ghcr.io/${{ github.repository }}
|
||||
|
||||
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- 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 }}
|
|
@ -21,36 +21,15 @@ cd /data
|
|||
|
||||
WRITEFREELY=/writefreely/writefreely
|
||||
|
||||
if [ -e ./config.ini ] && [ -e ./writefreely.db ] && [ -e ./keys/email.aes256 ]; then
|
||||
BACKUP="writefreely.$(date +%s).db"
|
||||
cp writefreely.db ${BACKUP}
|
||||
if [ -e ./config.ini ] && [ -e ./keys/email.aes256 ]; then
|
||||
${WRITEFREELY} -migrate
|
||||
if cmp writefreely.db ${BACKUP}; then
|
||||
rm ${BACKUP}
|
||||
else
|
||||
echo "Database backed up at /data/${BACKUP}"
|
||||
fi
|
||||
exec ${WRITEFREELY}
|
||||
fi
|
||||
|
||||
if [ -e ./config.ini ]; then
|
||||
if [ ! -s ./writefreely.db ]; then
|
||||
${WRITEFREELY} -init-db
|
||||
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}
|
||||
|
||||
fi
|
||||
|
||||
WRITEFREELY_BIND_PORT="${WRITEFREELY_BIND_PORT:-8080}"
|
||||
|
@ -70,12 +49,11 @@ pages_parent_dir = /writefreely
|
|||
keys_parent_dir =
|
||||
|
||||
[database]
|
||||
type = sqlite3
|
||||
filename = writefreely.db
|
||||
username =
|
||||
password =
|
||||
database =
|
||||
host = localhost
|
||||
type = mysql
|
||||
username = ${WRITEFREELY_DATABASE_USERNAME}
|
||||
password = ${WRITEFREELY_DATABASE_PASSWORD}
|
||||
database = ${WRITEFREELY_DATABASE_NAME}
|
||||
host = ${WRITEFREELY_DATABASE_HOST}
|
||||
port = 3306
|
||||
|
||||
[app]
|
||||
|
|
Loading…
Add table
Reference in a new issue