Compare commits

..

1 Commits

Author SHA1 Message Date
689dd5e58e chore(deps): update dependency pylint to v3.3.3
All checks were successful
CI w/ Poetry and Docker / ci (pull_request) Successful in 1m21s
2025-01-02 18:02:20 +00:00
2 changed files with 152 additions and 51 deletions

View File

@ -1,4 +1,4 @@
name: CI name: CI w/ Poetry and Docker
on: on:
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]

View File

@ -6,8 +6,7 @@ on:
types: [created] types: [created]
jobs: jobs:
manual_trigger: check_manual_trigger:
name: Manual Trigger Cleanup
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ gitea.event_name == 'issue_comment' }} if: ${{ gitea.event_name == 'issue_comment' }}
steps: steps:
@ -23,9 +22,23 @@ jobs:
- name: Delete issue comment - name: Delete issue comment
run: | run: |
curl -X DELETE \ curl -X DELETE -H "Authorization: token ${{ gitea.token }}" "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/issues/comments/${{ gitea.event.comment.id }}"
-H "Authorization: token ${{ gitea.token }}" \
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/issues/comments/${{ gitea.event.comment.id }}" # get_last_tag:
# name: Get last tag
# runs-on: ubuntu-latest
# needs: check_manual_trigger
# outputs:
# last_tag: ${{ steps.last_tag.outputs.last_tag }}
# steps:
# - uses: actions/checkout@v4.2.2
# with:
# fetch-depth: 0
# - name: Get last tag
# id: last_tag
# run: |
# LASTTAG=$(git describe --tags --abbrev=0)
# echo "last_tag=$LASTTAG" >> "$GITEA_OUTPUT"
# test: # test:
# name: Unit Test # name: Unit Test
@ -36,21 +49,29 @@ jobs:
name: Create Release name: Create Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
# needs: test # needs: test
# needs: get_last_tag
outputs: outputs:
release_name: ${{ steps.get_next_version.outputs.tag }} release_name: ${{ steps.tag_version.outputs.new_tag }}
success: ${{ steps.set_flag.outputs.success }}
steps: steps:
- name: Check out repository - uses: actions/checkout@v4.2.2
uses: actions/checkout@v4.2.2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Changes since last tag - name: Changes since last tag
id: changes id: changes
run: | run: |
rm -f .changes rm -f .changes .changes_feat .changes_fix .changes_dep .changes_other
git log $(git describe --tags --abbrev=0)..HEAD --no-merges --oneline >> .changes git log $(git describe --tags --abbrev=0)..HEAD --no-merges --oneline >> .changes
cat .changes cat .changes
- name: Upload changelog file
uses: actions/upload-artifact@v3
with:
name: changelog-file
path: ./.changes
include-hidden-files: true
- name: Check for changes - name: Check for changes
run: | run: |
if [[ -z $(grep '[^[:space:]]' .changes) ]] ; then if [[ -z $(grep '[^[:space:]]' .changes) ]] ; then
@ -59,12 +80,38 @@ jobs:
else else
echo "changes=true" echo "changes=true"
echo "changes=true" >> "$GITEA_OUTPUT" echo "changes=true" >> "$GITEA_OUTPUT"
grep -i "feat" .changes >> .changes_feat || true
grep -i "fix" .changes >> .changes_fix || true
grep -i "dependencies" .changes >> .changes_dep || true
grep -i "other" .changes >> .changes_other || true
fi fi
- name: Cancel if no changes - name: Cancel if no changes
if: steps.changes.outputs.changes == 'false' if: steps.changes.outputs.changes == 'false'
run: exit 1 run: exit 1
# - name: Create changelog
# id: create_changelog
# if: steps.changes.outputs.changes == true
# run: |
# rm -f .changelog
# if [[ -z $(grep '[^[:space:]]' .changes_feat) ]] ; then
# printf "## 🚀 Features" > .changelog
# cat .changes_feat >> .changelog
# fi
# if [[ -z $(grep '[^[:space:]]' .changes_fix) ]] ; then
# printf "## 🐛 Bug Fixes" >> .changelog
# cat .changes_fix >> .changelog
# fi
# if [[ -z $(grep '[^[:space:]]' .changes_dep) ]] ; then
# printf "## 📦 Dependencies" >> .changelog
# cat .changes_dep >> .changelog
# fi
# if [[ -z $(grep '[^[:space:]]' .changes_other) ]] ; then
# printf "## 💬 Other" >> .changelog
# cat .changes_other >> .changelog
# fi
- name: Set server URL - name: Set server URL
id: set_srvurl id: set_srvurl
run: | run: |
@ -87,32 +134,93 @@ jobs:
- name: Create release - name: Create release
run: | run: |
curl -s -X POST \ curl -X POST \
-H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \ -H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \
-H "accept: application/json" \ -H "accept: application/json" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\": \"${{ steps.get_next_version.outputs.tag }}\", \"name\": \"${{ steps.get_next_version.outputs.tag }}\", \"body\": \"${{ steps.get_next_version.outputs.changelog }}\"}" \ -d "{\"tag_name\": \"${{ steps.get_next_version.outputs.tag }}\", \"name\": \"${{ steps.get_next_version.outputs.tag }}\", \"body\": \"${{ steps.get_next_version.outputs.changelog }}\"}" \
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases"
build_docker: # - name: Create release
name: Build Docker Images # id: create_release
needs: create_release # uses: akkuman/gitea-release-action@v1
steps: # env:
- name: Update Docker configuration # NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
continue-on-error: true # with:
run: | # tag: ${{ steps.get_next_version.outputs.tag }}
mkdir -p /etc/default # name: ${{ steps.get_next_version.outputs.tag }}
mkdir -p /etc/docker # # body_path: .changelog
touch -a /etc/default/docker # body: ${{ steps.get_next_version.outputs.changelog }}
touch -a /etc/docker/daemon.json
echo "DOCKER_OPTS=\"--insecure-registry ${{ vars.PACKAGES_REGISTRY_URL }}\"" >> /etc/default/docker
echo "{\"insecure-registries\": [\"${{ vars.PACKAGES_REGISTRY_URL }}\"]}" > /etc/docker/daemon.json
- name: Check out repository - name: Set success/fail flag
uses: actions/checkout@v4 id: set_flag
if: steps.changes.outputs.changes == 'true'
run: if test "${{ steps.changes.outputs.changes }}" = "true"; then echo "success=true" >> "$GITEA_OUTPUT"; else echo "success=false" >> "$GITEA_OUTPUT"; fi
build_docker_ghcr:
name: Build GHCR Docker Images
needs: create_release
if: ${{ needs.create_release.outputs.success == 'true' }}
outputs:
success: ${{ steps.set_flag.outputs.success }}
with:
release: ${{ needs.create_release.outputs.release_name }}
steps:
- uses: actions/checkout@v4
with: with:
fetch-depth: 0 ref: ${{ inputs.release }}
ref: ${{ needs.create_release.outputs.release_name }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: luketainton
password: ${{ secrets.GHCR_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/luketainton/webexmemebot
tags: type=semver,pattern=v{{version}},value=${{ inputs.release }}
- name: Build and push images
id: build_push
uses: docker/build-push-action@v6
with:
context: .
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
ghcr.io/luketainton/webexmemebot:latest
ghcr.io/luketainton/webexmemebot:${{ inputs.release }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/luketainton/webexmemebot
subject-digest: ${{ steps.build_push.outputs.digest }}
push-to-registry: true
- name: Set success flag
id: set_flag
run: echo "success=true" >> "$GITEA_OUTPUT"
build_docker_gitea:
name: Build Gitea Docker Images
needs: create_release
if: ${{ needs.create_release.outputs.success == 'true' }}
outputs:
success: ${{ steps.set_flag.outputs.success }}
with:
release: ${{ needs.create_release.outputs.release_name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.release }}
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -121,30 +229,23 @@ jobs:
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ vars.PACKAGES_REGISTRY_URL }} registry: ${{ vars.PACKAGES_REGISTRY_URL }}
username: ${{ vars.ACTIONS_USERNAME }} username: ${{ vars.PACKAGES_REGISTRY_USERNAME }}
password: ${{ secrets.ACTIONS_TOKEN }} password: ${{ vars.PACKAGES_REGISTRY_PASSWORD }}
- name: Log in to GitHub Container Registry - name: Build Gitea image(s)
uses: docker/login-action@v3 uses: docker/build-push-action@v6
with:
registry: ghcr.io
username: ${{ vars.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ vars.GHCR_USERNAME }}/webexmemebot
${{ vars.PACKAGES_REGISTRY_URL }}/${{ gitea.repository }}
tags: type=semver,pattern=v{{version}},value=${{ needs.create_release.outputs.release_name }}
- name: Build and push images
uses: docker/build-push-action@v5
with: with:
context: . context: .
push: true push: false
annotations: ${{ steps.meta.outputs.annotations }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }} tags: |
${{ vars.PACKAGES_REGISTRY_URL }}/${{ gitea.repository }}:latest
${{ vars.PACKAGES_REGISTRY_URL }}/${{ gitea.repository }}:${{ inputs.release }}
- name: Push Gitea image(s)
run:
docker push ${{ vars.PACKAGES_REGISTRY_URL }}/${{ gitea.repository }}:latest ${{ vars.PACKAGES_REGISTRY_URL }}/${{ gitea.repository }}:${{ inputs.release }}
- name: Set success flag
id: set_flag
run: echo "success=true" >> "$GITEA_OUTPUT"