8000 new github action methodology and update readme with attachment changes · homeylab/bookstack-file-exporter@3c7a61e · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c7a61e

Browse files
committed
new github action methodology and update readme with attachment changes
1 parent 1e4f870 commit 3c7a61e

File tree

15 files changed

+436
-128
lines changed

15 files changed

+436
-128
lines changed

.github/actions/docker/action.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
name: Docker image
3+
description: Creates a Docker image
4+
5+
# note inputs have some weird behavior: https://github.com/actions/runner/issues/1483
6+
# for string type, don't wrap in JSON
7+
# for boolean type, wrap in JSON
8+
9+
inputs:
10+
dockerhub_username:
11+
description: Dockerhub username
12+
type: string
13+
required: false
14+
default: none
15+
dockerhub_token:
16+
description: Dockerhub token
17+
type: string
18+
required: false
19+
default: none
20+
push:
21+
description: Push Images to docker hub
22+
type: boolean
23+
required: false
24+
default: true
25+
latest:
26+
description: Update latest tag
27+
type: boolean
28+
required: false
29+
default: true
30+
31+
runs:
32+
using: composite
33+
steps:
34+
- name: Docker meta
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: docker.io/${{ github.repository }}
39+
flavor: |
40+
latest=${{ fromJSON(inputs.latest) }}
41+
# for some reason can't get this to show up from docker image labels
42+
# placing here for now
43+
labels: |
44+
org.opencontainers.image.description=Page asset and content exporter for Bookstack
45+
tags: |
46+
## add the event types that should be added as tags
47+
## on merge to master - update `main` tag for testing before release
48+
type=ref,event=branch
49+
## on release - for use by users
50+
type=semver,pattern={{major}}.{{minor}}
51+
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
55+
- name: Set up Docker Buildx
56+
id: buildx
57+
uses: docker/setup-buildx-action@v3
58+
59+
- name: Login to Dockerhub
60+
if: github.event_name != 'pull_request'
61+
uses: docker/login-action@v3
62+
with:
63+
username: ${{ inputs.dockerhub_username }}
64+
password: ${{ inputs.dockerhub_token }}
65+
66+
- name: Build Docker Image
67+
if: github.event_name != 'pull_request'
68+
uses: docker/build-push-action@v5
69+
with:
70+
context: .
71+
file: ./Dockerfile
72+
platforms: linux/amd64,linux/arm64
73+
push: ${{ fromJSON(inputs.push) }}
74+
tags: ${{ steps.meta.outputs.tags }}
75+
labels: ${{ steps.meta.outputs.labels }}
76+
77+
- name: Update Dockerhub Documentation
78+
uses: peter-evans/dockerhub-description@v3
79+
if: ${{ (fromJSON(inputs.latest) == true) && (github.event_name != 'pull_request') }}
80+
with:
81+
username: ${{ inputs.dockerhub_username }}
82+
password: ${{ inputs.dockerhub_token }}
83+
repository: ${{ github.repository }}

.github/actions/python/action.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Deploy to PyPi
3+
description: Deploys the python package to PyPi
4+
5+
inputs:
6+
pypi_api_token:
7+
description: PyPi api token
8+
type: string
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Get tag release without v
15+
run: 10000 |
16+
TAG=${{ github.ref_name }}
17+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
18+
echo "Tag without v is: ${VERSION}"
19+
- name: Update Release Tag
20+
run: sed -i "s/^version = [^ ]*/version = ${{ env.VERSION }}/" setup.cfg
21+
- name: Set up Python
22+
uses: actions/setup-python@v3
23+
with:
24+
python-version: '3.12.1'
25+
- name: Install Dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install build
29+
- name: Build Python Package
30+
run: |
31+
python -m pip install --upgrade build
32+
python -m build
33+
- name: Publish to PyPi
34+
uses: pypa/gh-action-pypi-publish@release/v1
35+
with:
36+
password: ${{ inputs.pypi_api_token }}
37+
skip-existing: true

.github/actions/tests/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Test Python Package
3+
description: Test and lint code
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Set up Python
9+
uses: actions/setup-python@v3
10+
with:
11+
python-version: '3.12.1'
12+
- name: Install dependencies
13+
run: |
14+
python -m pip install --upgrade pip
15+
pip install pylint
16+
- name: Analysing the code with pylint
17+
run: |
18+
pylint $(git ls-files '*.py')
File renamed without changes.

.github/bkp/on_pr_merged.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# needs: [tests] # require tests to pass before deploy runs
2+
3+
name: Build and Push
4+
5+
# on:
6+
# push:
7+
# # Pattern matched against refs/tags
8+
# tags:
9+
# - '**' # Push events to every tag including hierarchical tags like v1.0/beta
10+
11+
on:
12+
pull_request:
13+
types:
14+
- closed
15+
branches:
16+
- main
17+
18+
# maybe trigger build/push on release tags?
19+
# but this also works for my use case
20+
jobs:
21+
docker_deploy:
22+
if: github.event.pull_request.merged
23+
runs-on: ubuntu-latest
24+
# specify this to target the correct env/secrets to use
25+
environment: 'Dockerhub'
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Login to Dockerhub
29+
uses: docker/login-action@v3
30+
with:
31+
username: ${{ secrets.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
- name: Set up Docker Buildx
36+
id: buildx
37+
uses: docker/setup-buildx-action@v3
38+
- name: Build and push the Docker image
39+
run: make docker_build_latest
40+
# - name: Push Docker image
41+
# run: make docker_push_latest
42+
- name: Update Dockerhub Documentation
43+
uses: peter-evans/dockerhub-description@v3
44+
with:
45+
username: ${{ secrets.DOCKERHUB_USERNAME }}
46+
password: ${{ secrets.DOCKERHUB_TOKEN }}
47+
repository: ${{ env.DOCKERHUB_REPO }}
48+
pypi_deploy:
49+
if: github.event.pull_request.merged
50+
runs-on: ubuntu-latest
51+
environment: 'PyPi'
52+
steps:
53+
- uses: actions/checkout@v3
54+
- name: Set up Python
55+
uses: actions/setup-python@v3
56+
with:
57+
python-version: '3.x'
58+
- name: Set tag version
59+
run: |
60+
TAG=$(cat Makefile | grep -E ^IMAGE_TAG=[0-9].[0-9].[0-9] | cut -d "=" -f2)
61+
echo "VERSION=${TAG}" >> "$GITHUB_ENV"
62+
echo "version from Makefile is: ${VERSION}"
63+
- name: Install dependencies
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install build
67+
- name: Update Release tag
68+
run: sed -i "s/^version = [^ ]*/version = ${{ env.VERSION }}/" setup.cfg
69+
- name: Build package
70+
run: make build
71+
- name: Publish package
72+
uses: pypa/gh-action-pypi-publish@release/v1
73+
with:
74+
password: ${{ secrets.PYPI_API_TOKEN }}
75+
skip-existing: true
76+
create_tag:
77+
if: github.event.pull_request.merged
78+
runs-on: ubuntu-latest
79+
needs:
80+
- docker_deploy
81+
- pypi_deploy
82+
permissions:
83+
contents: write
84+
steps:
85+
- uses: actions/checkout@v3
86+
with:
87+
ref: ${{ github.event.pull_request.merge_commit_sha }}
88+
fetch-depth: '0'
89+
- name: Set tag version
90+
run: |
91+
TAG=$(cat Makefile | grep -E ^IMAGE_TAG=[0-9].[0-9].[0-9] | cut -d "=" -f2)
92+
echo "VERSION=v${TAG}" >> "$GITHUB_ENV"
93+
echo "version from Makefile is: ${VERSION}"
94+
- name: Create tag
95+
uses: anothrNick/github-tag-action@1.64.0
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
# WITH_V: true
99+
# PRERELEASE: true
100+
CUSTOM_TAG: ${{ env.VERSION }}
101+
create_release:
102+
if: github.event.pull_request.merged
103+
runs-on: ubuntu-latest
104+
needs:
105+
- create_tag
106+
permissions:
107+
contents: write
108+
steps:
109+
- uses: actions/checkout@v3
110+
- name: Set tag version
111+
run: |
112+
TAG=$(cat Makefile | grep -E ^IMAGE_TAG=[0-9].[0-9].[0-9] | cut -d "=" -f2)
113+
echo "VERSION=v${TAG}" >> "$GITHUB_ENV"
114+
echo "version from Makefile is: ${VERSION}"
115+
- name: Generate release
116+
uses: ncipollo/release-action@v1
117+
with:
118+
tag: ${{ env.VERSION }}
119+
generateReleaseNotes: true
120+
skipIfReleaseExists: true
121+
# docker image tag latest

0 commit comments

Comments
 (0)
0