mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-04 22:24:42 +09:00
Add CI job summaries and GHCR package cleanup workflow (#3567)
* Add GHCR package cleanup workflow * Add job summaries to CI workflows * Add create-release workflow; update release-docker * Improve auto-cs-fix workflow: caching and summary * Use GHCR build-cache image and mirror manifests * Remove prepare-application-assets action * Standardize workflow step names and cache image
This commit is contained in:
1 parent
4ffffff85c
commit
f43e07cb64
9 files changed
+300
-124
No files matched your search
@@ -1,88 +0,0 @@
|
||||
name: 'Prepare Application Assets'
|
||||
description: 'Build frontend assets, fetch translations, and stage required project files.'
|
||||
inputs:
|
||||
cache-theme-builds:
|
||||
description: 'Whether to cache built admin_default and huraga theme assets.'
|
||||
required: false
|
||||
default: 'false'
|
||||
install-command:
|
||||
description: 'The command used to install Node.js dependencies.'
|
||||
required: false
|
||||
default: 'npm ci'
|
||||
build-command:
|
||||
description: 'The command used to build frontend assets.'
|
||||
required: false
|
||||
default: 'npm run build'
|
||||
node-version:
|
||||
description: 'The Node.js version to use for the frontend build.'
|
||||
required: false
|
||||
default: '24'
|
||||
remove-admin-node-modules:
|
||||
description: 'Whether to remove admin_default node_modules after preparing the tree.'
|
||||
required: false
|
||||
default: 'false'
|
||||
translations-url:
|
||||
description: 'The URL used to download translations.'
|
||||
required: false
|
||||
default: 'https://github.com/FOSSBilling/locale/releases/latest/download/translations.zip'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Make theme build directories
|
||||
if: ${{ inputs.cache-theme-builds == 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ./src/themes/admin_default/build
|
||||
mkdir -p ./src/themes/huraga/build
|
||||
|
||||
- name: Cache Built Admin Theme
|
||||
if: ${{ inputs.cache-theme-builds == 'true' }}
|
||||
id: cache-admin_default
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
with:
|
||||
path: ./src/themes/admin_default/build
|
||||
key: admin_default-${{ hashFiles('./package-lock.json', './src/themes/admin_default/assets/fossbilling.js', './src/themes/admin_default/assets/scss/*.scss', './src/themes/admin_default/assets/js/*.js', './src/themes/admin_default/assets/js/ui/*.js') }}
|
||||
|
||||
- name: Cache Built Huraga Theme
|
||||
if: ${{ inputs.cache-theme-builds == 'true' }}
|
||||
id: cache-huraga
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
with:
|
||||
path: ./src/themes/huraga/build
|
||||
key: huraga-${{ hashFiles('./package-lock.json', './src/themes/huraga/assets/huraga.js', './src/themes/huraga/assets/scss/*.scss') }}
|
||||
|
||||
- name: Install Node.js and Enable Caching
|
||||
if: ${{ inputs.cache-theme-builds != 'true' || steps.cache-admin_default.outputs.cache-hit != 'true' || steps.cache-huraga.outputs.cache-hit != 'true' }}
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
cache: 'npm'
|
||||
cache-dependency-path: '**/package-lock.json'
|
||||
node-version: ${{ inputs.node-version }}
|
||||
|
||||
- name: Install Node.js Dependencies
|
||||
if: ${{ inputs.cache-theme-builds != 'true' || steps.cache-admin_default.outputs.cache-hit != 'true' || steps.cache-huraga.outputs.cache-hit != 'true' }}
|
||||
shell: bash
|
||||
run: ${{ inputs.install-command }}
|
||||
|
||||
- name: Build Frontend Assets
|
||||
if: ${{ inputs.cache-theme-builds != 'true' || steps.cache-admin_default.outputs.cache-hit != 'true' || steps.cache-huraga.outputs.cache-hit != 'true' }}
|
||||
shell: bash
|
||||
run: ${{ inputs.build-command }}
|
||||
|
||||
- name: Download Latest Translations
|
||||
shell: bash
|
||||
run: |
|
||||
wget "${{ inputs.translations-url }}" -O translations.zip
|
||||
mkdir -p ./src/locale
|
||||
unzip -o translations.zip -d ./src/locale
|
||||
|
||||
- name: Copy Required Files and Clean-up
|
||||
shell: bash
|
||||
run: |
|
||||
cp README.md ./src/
|
||||
cp LICENSE ./src/
|
||||
rm translations.zip
|
||||
|
||||
if [[ "${{ inputs.remove-admin-node-modules }}" == 'true' ]]; then
|
||||
rm -rf ./src/themes/admin_default/node_modules/
|
||||
fi
|
||||
@@ -20,23 +20,24 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: PHP Build
|
||||
uses: FOSSBilling/.workflows/.github/actions/php-build@76b4af76fb2a1a2b553ec1c2839044984299a271
|
||||
with:
|
||||
php-version: 8.3
|
||||
|
||||
- name: Setup PHP
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
|
||||
with:
|
||||
php-version: 8.3
|
||||
extensions: intl, xml, dom, curl, iconv, json
|
||||
|
||||
|
||||
- name: Create Cache Directories
|
||||
run: |
|
||||
echo "MONTH=$(date '+%h')" >> "${GITHUB_ENV}"
|
||||
mkdir cache
|
||||
mkdir cache/rector
|
||||
mkdir -p cache/rector
|
||||
|
||||
- name: Restore Rector Cache
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
@@ -44,7 +45,7 @@ jobs:
|
||||
path: ./cache/rector
|
||||
key: ${{ env.MONTH }}-rector
|
||||
restore-keys: ${{ env.MONTH }}-rector
|
||||
|
||||
|
||||
- name: Restore CS-Fixer Cache
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
with:
|
||||
@@ -53,12 +54,15 @@ jobs:
|
||||
restore-keys: ${{ env.MONTH }}-csfixer
|
||||
|
||||
- name: Run Rector
|
||||
id: rector
|
||||
run: php src/vendor/bin/rector
|
||||
|
||||
|
||||
- name: Run PHP-CS-Fixer
|
||||
id: php_cs_fixer
|
||||
run: php src/vendor/bin/php-cs-fixer fix
|
||||
|
||||
- name: Create a Pull Request
|
||||
|
||||
- name: Create Pull Request
|
||||
id: create_pr
|
||||
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
|
||||
with:
|
||||
title: Apply PHP Code Styling & Quality Changes
|
||||
@@ -70,3 +74,18 @@ jobs:
|
||||
committer: FOSSBilling Bot <fossbilling-bot>
|
||||
author: FOSSBilling Bot <fossbilling-bot>
|
||||
labels: skip-changelog
|
||||
|
||||
- name: Write Job Summary
|
||||
if: always()
|
||||
run: |
|
||||
cat >> "${GITHUB_STEP_SUMMARY}" <<'EOF'
|
||||
## Code Quality and Styling
|
||||
|
||||
| Item | Value |
|
||||
| --- | --- |
|
||||
| PHP version | `8.3` |
|
||||
| Rector | `${{ steps.rector.outcome }}` |
|
||||
| PHP-CS-Fixer | `${{ steps.php_cs_fixer.outcome }}` |
|
||||
| Pull request action | `${{ steps.create_pr.outcome }}` |
|
||||
| Pull request | `${{ steps.create_pr.outputs.pull-request-url || 'No changes' }}` |
|
||||
EOF
|
||||
@@ -0,0 +1,129 @@
|
||||
name: Create Release
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Release version, for example 0.7.3'
|
||||
required: true
|
||||
type: string
|
||||
target_ref:
|
||||
description: 'Git ref to build and tag'
|
||||
required: true
|
||||
default: main
|
||||
type: string
|
||||
draft:
|
||||
description: 'Create as a draft release'
|
||||
required: true
|
||||
default: true
|
||||
type: boolean
|
||||
prerelease:
|
||||
description: 'Mark as a prerelease'
|
||||
required: true
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
concurrency:
|
||||
group: create-release-${{ inputs.version }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
name: 'Create Release'
|
||||
if: ${{ github.repository == 'FOSSBilling/FOSSBilling' }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- name: 'Validate Release Inputs'
|
||||
run: |
|
||||
if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
|
||||
echo "Release version must be valid SemVer without a leading v."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
ref: ${{ inputs.target_ref }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: 'Set Registry Cache Image'
|
||||
run: echo "CACHE_IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}-build-cache" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: 'Set up Docker Buildx'
|
||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
|
||||
|
||||
- name: 'Build Release Artifact'
|
||||
id: build
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
build-args: |
|
||||
FOSSBILLING_VERSION=${{ inputs.version }}
|
||||
SENTRY_DSN=${{ vars.SENTRY_DSN }}
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-release
|
||||
context: .
|
||||
target: release-artifact
|
||||
outputs: type=local,dest=./release-tree
|
||||
|
||||
- name: 'Create Release Archive'
|
||||
id: archive
|
||||
run: |
|
||||
mkdir -p ../dist
|
||||
zip -qr "../dist/FOSSBilling-${{ inputs.version }}.zip" .
|
||||
working-directory: ./release-tree
|
||||
|
||||
- name: 'Create or Update GitHub Release'
|
||||
id: release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
asset="./dist/FOSSBilling-${{ inputs.version }}.zip"
|
||||
|
||||
if gh release view "${{ inputs.version }}" --repo "${{ github.repository }}" >/dev/null 2>&1; then
|
||||
gh release upload "${{ inputs.version }}" "${asset}" \
|
||||
--repo "${{ github.repository }}" \
|
||||
--clobber
|
||||
echo "operation=updated" >> "${GITHUB_OUTPUT}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
release_args=(
|
||||
"${{ inputs.version }}"
|
||||
"${asset}"
|
||||
--repo "${{ github.repository }}"
|
||||
--title "${{ inputs.version }}"
|
||||
--target "${{ inputs.target_ref }}"
|
||||
--generate-notes
|
||||
)
|
||||
|
||||
if [[ "${{ inputs.draft }}" == "true" ]]; then
|
||||
release_args+=(--draft)
|
||||
fi
|
||||
|
||||
if [[ "${{ inputs.prerelease }}" == "true" ]]; then
|
||||
release_args+=(--prerelease)
|
||||
fi
|
||||
|
||||
gh release create "${release_args[@]}"
|
||||
echo "operation=created" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: 'Write Job Summary'
|
||||
if: always()
|
||||
run: |
|
||||
cat >> "${GITHUB_STEP_SUMMARY}" <<'EOF'
|
||||
## Create Release
|
||||
|
||||
| Item | Value |
|
||||
| --- | --- |
|
||||
| Version | `${{ inputs.version }}` |
|
||||
| Target ref | `${{ inputs.target_ref }}` |
|
||||
| Draft | `${{ inputs.draft }}` |
|
||||
| Prerelease | `${{ inputs.prerelease }}` |
|
||||
| Archive | `FOSSBilling-${{ inputs.version }}.zip` |
|
||||
| Docker build | `${{ steps.build.outcome }}` |
|
||||
| Archive creation | `${{ steps.archive.outcome }}` |
|
||||
| Release operation | `${{ steps.release.outputs.operation || steps.release.outcome }}` |
|
||||
EOF
|
||||
@@ -66,8 +66,8 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: 'Lowercase github.repository'
|
||||
run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
|
||||
- name: 'Set Registry Cache Image'
|
||||
run: echo "CACHE_IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}-build-cache" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: 'Set Release Tree Artifact Output'
|
||||
id: release-tree-output
|
||||
@@ -104,8 +104,8 @@ jobs:
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
build-args: ${{ inputs.build-args }}
|
||||
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:${{ inputs.cache-scope }}
|
||||
cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:${{ inputs.cache-scope }},mode=max
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:${{ inputs.cache-scope }}
|
||||
cache-to: type=registry,ref=${{ env.CACHE_IMAGE }}:${{ inputs.cache-scope }},mode=max
|
||||
context: .
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
outputs: type=image,name=docker.io/${{ inputs.meta-images }},name-canonical=true,push=true,push-by-digest=true
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
build-args: ${{ inputs.build-args }}
|
||||
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:${{ inputs.cache-scope }}
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:${{ inputs.cache-scope }}
|
||||
context: .
|
||||
outputs: type=local,dest=./release-tree
|
||||
target: release-artifact
|
||||
@@ -202,7 +202,24 @@ jobs:
|
||||
|
||||
docker buildx imagetools create "${tag_args[@]}" "${digest_args[@]}"
|
||||
|
||||
- name: 'Mirror Manifest List to GHCR'
|
||||
run: |
|
||||
mapfile -t docker_tags < <(jq -r '.tags[]' <<< "$DOCKER_METADATA_OUTPUT_JSON")
|
||||
ghcr_tag_args=()
|
||||
for tag in "${docker_tags[@]}"; do
|
||||
ghcr_tag_args+=(-t "ghcr.io/${tag#docker.io/}")
|
||||
done
|
||||
|
||||
docker buildx imagetools create \
|
||||
"${ghcr_tag_args[@]}" \
|
||||
"docker.io/${{ inputs.meta-images }}:${{ steps.meta.outputs.version }}"
|
||||
|
||||
- name: 'Inspect Image'
|
||||
run: |
|
||||
docker buildx imagetools inspect \
|
||||
'docker.io/${{ inputs.meta-images }}:${{ steps.meta.outputs.version }}'
|
||||
|
||||
- name: 'Inspect GHCR Image'
|
||||
run: |
|
||||
docker buildx imagetools inspect \
|
||||
'ghcr.io/${{ inputs.meta-images }}:${{ steps.meta.outputs.version }}'
|
||||
@@ -0,0 +1,39 @@
|
||||
name: GHCR Package Cleanup
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '37 3 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ghcr-package-cleanup
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
name: 'Delete Untagged GHCR Versions'
|
||||
if: ${{ github.repository == 'FOSSBilling/FOSSBilling' }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: 'Delete Untagged Runtime Image Versions'
|
||||
uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5
|
||||
with:
|
||||
owner: FOSSBilling
|
||||
package-name: fossbilling
|
||||
package-type: container
|
||||
delete-only-untagged-versions: 'true'
|
||||
min-versions-to-keep: 20
|
||||
|
||||
- name: 'Delete Untagged Build Cache Versions'
|
||||
uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5
|
||||
with:
|
||||
owner: FOSSBilling
|
||||
package-name: fossbilling-build-cache
|
||||
package-type: container
|
||||
delete-only-untagged-versions: 'true'
|
||||
min-versions-to-keep: 20
|
||||
@@ -14,9 +14,8 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: 'Lowercase github.repository'
|
||||
run: |
|
||||
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
|
||||
- name: 'Set Registry Cache Image'
|
||||
run: echo "CACHE_IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}-build-cache" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: 'Set up Docker Compose'
|
||||
uses: docker/setup-compose-action@8cccb8c14b6500aaffebff1aa49c502c34d2e5e6 # v2.1.0
|
||||
@@ -26,12 +25,13 @@ jobs:
|
||||
|
||||
# This job runs checked-out live-test code, so it only reads the registry cache.
|
||||
- name: 'Build Docker Test Image'
|
||||
id: build
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
build-args: |
|
||||
PHP_VERSION=8.5
|
||||
INSTALL_TRANSLATIONS=false
|
||||
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-ci-8.5
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-ci-8.5
|
||||
context: .
|
||||
load: true
|
||||
tags: |
|
||||
@@ -39,4 +39,22 @@ jobs:
|
||||
target: test
|
||||
|
||||
- name: 'Run Live Tests'
|
||||
id: live_tests
|
||||
run: bash ./.github/scripts/run-docker-live-tests.sh fossbilling:live-test
|
||||
|
||||
- name: 'Write Job Summary'
|
||||
if: always()
|
||||
run: |
|
||||
cat >> "${GITHUB_STEP_SUMMARY}" <<'EOF'
|
||||
## Live Tests
|
||||
|
||||
| Item | Value |
|
||||
| --- | --- |
|
||||
| Test image | `fossbilling:live-test` |
|
||||
| PHP version | `8.5` |
|
||||
| Registry cache | `${{ env.CACHE_IMAGE }}:cache-ci-8.5` |
|
||||
| Cache mode | `read-only` |
|
||||
| Compose file | `.github/docker/live-tests.compose.yml` |
|
||||
| Docker build | `${{ steps.build.outcome }}` |
|
||||
| Live tests | `${{ steps.live_tests.outcome }}` |
|
||||
EOF
|
||||
@@ -22,9 +22,8 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: 'Lowercase github.repository'
|
||||
run: |
|
||||
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
|
||||
- name: 'Set Registry Cache Image'
|
||||
run: echo "CACHE_IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}-build-cache" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: 'Login to GitHub Container Registry'
|
||||
if: inputs.write-cache
|
||||
@@ -38,13 +37,14 @@ jobs:
|
||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
|
||||
|
||||
- name: 'Build Docker Test Image'
|
||||
id: build_read_cache
|
||||
if: ${{ !inputs.write-cache }}
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
build-args: |
|
||||
PHP_VERSION=${{ matrix.php }}
|
||||
INSTALL_TRANSLATIONS=false
|
||||
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-ci-${{ matrix.php }}
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }}
|
||||
context: .
|
||||
load: true
|
||||
tags: |
|
||||
@@ -52,14 +52,15 @@ jobs:
|
||||
target: test
|
||||
|
||||
- name: 'Build Docker Test Image'
|
||||
id: build_write_cache
|
||||
if: inputs.write-cache
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
build-args: |
|
||||
PHP_VERSION=${{ matrix.php }}
|
||||
INSTALL_TRANSLATIONS=false
|
||||
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-ci-${{ matrix.php }}
|
||||
cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-ci-${{ matrix.php }},mode=max
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }}
|
||||
cache-to: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }},mode=max
|
||||
context: .
|
||||
load: true
|
||||
tags: |
|
||||
@@ -67,6 +68,7 @@ jobs:
|
||||
target: test
|
||||
|
||||
- name: 'PHPStan'
|
||||
id: phpstan
|
||||
run: |
|
||||
docker run --rm \
|
||||
--env APP_ENV=test \
|
||||
@@ -74,8 +76,26 @@ jobs:
|
||||
./src/vendor/bin/phpstan analyse --configuration phpstan.neon --memory-limit=512M
|
||||
|
||||
- name: 'PHPUnit'
|
||||
id: phpunit
|
||||
run: |
|
||||
docker run --rm \
|
||||
--env APP_ENV=test \
|
||||
fossbilling:test-${{ matrix.php }} \
|
||||
./src/vendor/bin/phpunit --configuration phpunit.xml.dist
|
||||
|
||||
- name: 'Write Job Summary'
|
||||
if: always()
|
||||
run: |
|
||||
cat >> "${GITHUB_STEP_SUMMARY}" <<'EOF'
|
||||
## PHP Build and Test
|
||||
|
||||
| Item | Value |
|
||||
| --- | --- |
|
||||
| PHP version | `${{ matrix.php }}` |
|
||||
| Test image | `fossbilling:test-${{ matrix.php }}` |
|
||||
| Registry cache | `${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }}` |
|
||||
| Cache mode | `${{ inputs.write-cache && 'read/write' || 'read-only' }}` |
|
||||
| Docker build | `${{ inputs.write-cache && steps.build_write_cache.outcome || steps.build_read_cache.outcome }}` |
|
||||
| PHPStan | `${{ steps.phpstan.outcome }}` |
|
||||
| PHPUnit | `${{ steps.phpunit.outcome }}` |
|
||||
EOF
|
||||
@@ -18,9 +18,8 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: 'Lowercase github.repository'
|
||||
run: |
|
||||
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
|
||||
- name: 'Set Registry Cache Image'
|
||||
run: echo "CACHE_IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}-build-cache" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: 'Login to GitHub Container Registry'
|
||||
if: inputs.write-cache
|
||||
@@ -34,6 +33,7 @@ jobs:
|
||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
|
||||
|
||||
- name: 'Build Release Artifact'
|
||||
id: build_read_cache
|
||||
if: ${{ !inputs.write-cache }}
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
@@ -41,12 +41,13 @@ jobs:
|
||||
FOSSBILLING_VERSION=${{ github.sha }}
|
||||
FOSSBILLING_VERSION_TRUNCATE=7
|
||||
SENTRY_DSN=${{ vars.SENTRY_DSN }}
|
||||
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-preview
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-preview
|
||||
context: .
|
||||
target: release-artifact
|
||||
outputs: type=local,dest=./release-tree
|
||||
|
||||
- name: 'Build Release Artifact'
|
||||
id: build_write_cache
|
||||
if: inputs.write-cache
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
|
||||
with:
|
||||
@@ -54,19 +55,40 @@ jobs:
|
||||
FOSSBILLING_VERSION=${{ github.sha }}
|
||||
FOSSBILLING_VERSION_TRUNCATE=7
|
||||
SENTRY_DSN=${{ vars.SENTRY_DSN }}
|
||||
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-preview
|
||||
cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-preview,mode=max
|
||||
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-preview
|
||||
cache-to: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-preview,mode=max
|
||||
context: .
|
||||
target: release-artifact
|
||||
outputs: type=local,dest=./release-tree
|
||||
|
||||
- name: 'Create Preview Build Archive'
|
||||
id: archive
|
||||
run: tar -cf /tmp/build.tar -C ./release-tree ./
|
||||
|
||||
- name: 'Upload Preview Build Archive'
|
||||
id: upload
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
if-no-files-found: 'error'
|
||||
name: preview-build
|
||||
path: /tmp/build.tar
|
||||
retention-days: 1
|
||||
|
||||
- name: 'Write Job Summary'
|
||||
if: always()
|
||||
run: |
|
||||
cat >> "${GITHUB_STEP_SUMMARY}" <<'EOF'
|
||||
## Preview Build
|
||||
|
||||
| Item | Value |
|
||||
| --- | --- |
|
||||
| Release version | `${{ github.sha }}` |
|
||||
| Registry cache | `${{ env.CACHE_IMAGE }}:cache-preview` |
|
||||
| Cache mode | `${{ inputs.write-cache && 'read/write' || 'read-only' }}` |
|
||||
| Build target | `release-artifact` |
|
||||
| Build output | `./release-tree` |
|
||||
| Uploaded artifact | `preview-build` |
|
||||
| Docker build | `${{ inputs.write-cache && steps.build_write_cache.outcome || steps.build_read_cache.outcome }}` |
|
||||
| Archive | `${{ steps.archive.outcome }}` |
|
||||
| Artifact upload | `${{ steps.upload.outcome }}` |
|
||||
EOF
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Upload Release to Docker Hub
|
||||
name: Upload Release to Docker Registries
|
||||
|
||||
on:
|
||||
release:
|
||||
@@ -21,11 +21,11 @@ jobs:
|
||||
steps:
|
||||
- name: 'Get Latest Release Version Tag'
|
||||
id: get-latest
|
||||
uses: pozetroninc/github-action-get-latest-release@53d33d213ee71c72360e3c829caf7cee94ec21e2 # master
|
||||
with:
|
||||
excludes: 'prerelease,draft'
|
||||
repository: 'FOSSBilling/FOSSBilling'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
latest_release="$(gh api repos/${{ github.repository }}/releases/latest --jq '.tag_name')"
|
||||
echo "release=${latest_release}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: 'Check if Current Release Version is Latest'
|
||||
id: compare-latest
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
fi
|
||||
|
||||
deploy-release-docker:
|
||||
name: 'Build and Push Release to Docker Hub'
|
||||
name: 'Build and Push Release Image'
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
Reference in new issue
Block a user