CI: fix widget upload — cd module для gh release upload #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - develop | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout module repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| path: module | |
| - name: Checkout workflows repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: mikopbx/.github-workflows | |
| path: .github-workflows | |
| - name: Validate module configuration | |
| id: validate | |
| uses: ./.github-workflows/.github/actions/validate | |
| - name: Manage versions | |
| id: version | |
| uses: ./.github-workflows/.github/actions/versioning | |
| with: | |
| initial_version: "1.84" | |
| - name: Setup build environment | |
| uses: ./.github-workflows/.github/actions/docker-build | |
| with: | |
| php_version: ${{ steps.validate.outputs.php_version }} | |
| - name: Handle dependencies | |
| uses: ./.github-workflows/.github/actions/composer | |
| with: | |
| php_version: ${{ steps.validate.outputs.php_version }} | |
| - name: Cache Docker images | |
| uses: actions/cache@v3 | |
| id: docker-cache | |
| with: | |
| path: ${{ runner.temp }}/docker-cache-*.tar | |
| key: ${{ runner.os }}-docker-${{ hashFiles('module/**/Dockerfile') }} | |
| restore-keys: | | |
| ${{ runner.os }}-docker- | |
| - name: Replace OAuth placeholders | |
| env: | |
| AMO_CLIENT_ID: ${{ secrets.AMO_CLIENT_ID }} | |
| AMO_CLIENT_SECRET: ${{ secrets.AMO_CLIENT_SECRET }} | |
| AMO_REDIRECT_URL: ${{ secrets.AMO_REDIRECT_URL }} | |
| run: | | |
| cd module | |
| sed -i "s|%CLIENT_ID%|$AMO_CLIENT_ID|g" Lib/AmoCrmMainBase.php | |
| sed -i "s|%CLIENT_SECRET%|$AMO_CLIENT_SECRET|g" Lib/AmoCrmMainBase.php | |
| sed -i "s|%REDIRECT_URL%|$AMO_REDIRECT_URL|g" Lib/AmoCrmMainBase.php | |
| echo "AmoCrmMainBase.php placeholders replaced." | |
| - name: Build widget | |
| run: | | |
| cd module | |
| WIDGET_VERSION="1.0.$(git rev-list --count HEAD)" | |
| sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/manifest.json | |
| sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/script.js | |
| cd widget && zip -r "$RUNNER_TEMP/widget.zip" . -x "*.DS_Store*" && cd .. | |
| echo "Widget built: widget.zip (version $WIDGET_VERSION)" | |
| rm -rf widget | |
| echo "widget/ removed from module archive." | |
| - name: Sync translations from Core | |
| uses: ./.github-workflows/.github/actions/sync-translations | |
| - name: Create module package | |
| id: archive | |
| uses: ./.github-workflows/.github/actions/archive | |
| with: | |
| version: ${{ steps.version.outputs.new_version }} | |
| - name: Generate changelog | |
| id: changelog | |
| if: steps.validate.outputs.changelog_enabled == 'true' | |
| uses: ./.github-workflows/.github/actions/changelog | |
| - name: Publish module | |
| if: | | |
| github.ref == 'refs/heads/master' && | |
| steps.validate.outputs.publish_release == 'true' | |
| env: | |
| OWNCLOUD_AUTH: ${{ secrets.OWNCLOUD_AUTH }} | |
| WEBDAV_ROOT: ${{ secrets.WEBDAV_ROOT }} | |
| SHARE_API_URL: ${{ secrets.SHARE_API_URL }} | |
| MIKO_LIC_REST_VENDOR_ID: ${{ secrets.MIKO_LIC_REST_VENDOR_ID }} | |
| MIKO_LIC_REST_API_KEY: ${{ secrets.MIKO_LIC_REST_API_KEY }} | |
| MIKO_LIC_HOSTNAME: ${{ secrets.MIKO_LIC_HOSTNAME }} | |
| uses: ./.github-workflows/.github/actions/publish | |
| with: | |
| php_version: ${{ steps.validate.outputs.php_version }} | |
| module_filename: ${{ steps.archive.outputs.filename }} | |
| version: ${{ steps.version.outputs.new_version }} | |
| changelog: ${{ steps.changelog.outputs.changelog }} | |
| - name: Manage GitHub releases | |
| if: steps.validate.outputs.create_github_release == 'true' | |
| uses: ./.github-workflows/.github/actions/release | |
| with: | |
| version: ${{ steps.version.outputs.new_version }} | |
| version_tag: ${{ steps.version.outputs.new_version_tag }} | |
| module_filename: ${{ steps.archive.outputs.filename }} | |
| changelog: ${{ steps.changelog.outputs.changelog }} | |
| - name: Upload widget to release | |
| if: steps.validate.outputs.create_github_release == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| cd module | |
| TAG="${{ steps.version.outputs.new_version_tag }}" | |
| echo "Uploading widget.zip to release $TAG..." | |
| sleep 5 | |
| gh release upload "$TAG" "$RUNNER_TEMP/widget.zip" --clobber | |
| echo "widget.zip uploaded to release $TAG" |