|
| 1 | +name: Deploy to WordPress.org Repository |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - release |
| 7 | + release: |
| 8 | + types: [released] |
| 9 | + |
| 10 | +jobs: |
| 11 | + deploy_to_wp_repository: |
| 12 | + name: Deploy to WP.org |
| 13 | + runs-on: ubuntu-latest |
| 14 | + env: |
| 15 | + PLUGIN_SLUG: bit-integrations |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Install pnpm |
| 21 | + uses: pnpm/action-setup@v4 |
| 22 | + with: |
| 23 | + version: 9 |
| 24 | + run_install: false |
| 25 | + |
| 26 | + - name: Setup Node |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: 22 |
| 30 | + cache: "pnpm" |
| 31 | + cache-dependency-path: "frontend-dev/pnpm-lock.yaml" |
| 32 | + |
| 33 | + - name: Get pnpm store directory |
| 34 | + id: pnpm-cache |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 38 | +
|
| 39 | + - uses: actions/cache@v3 |
| 40 | + name: Setup pnpm cache |
| 41 | + with: |
| 42 | + path: ${{ env.STORE_PATH }} |
| 43 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 44 | + restore-keys: | |
| 45 | + ${{ runner.os }}-pnpm-store- |
| 46 | +
|
| 47 | + - name: Install frontend dependencies |
| 48 | + run: | |
| 49 | + cd frontend-dev |
| 50 | + pnpm install |
| 51 | +
|
| 52 | + - name: Check for SVN |
| 53 | + id: check_svn |
| 54 | + run: | |
| 55 | + if ! command -v svn &> /dev/null; then |
| 56 | + echo "SVN not found, installing..." |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install -y subversion |
| 59 | + else |
| 60 | + echo "SVN is already installed." |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Setup PHP |
| 64 | + id: setup-php |
| 65 | + uses: shivammathur/setup-php@v2 |
| 66 | + with: |
| 67 | + php-version: "8.x" |
| 68 | + tools: composer:v2, wp-cli |
| 69 | + |
| 70 | + - name: Determine if this is a release or push |
| 71 | + id: set-test-action |
| 72 | + run: | |
| 73 | + if [[ "${{ github.event_name }}" == "release" ]]; then |
| 74 | + echo "TEST_ACTION=false" >> $GITHUB_ENV |
| 75 | + else |
| 76 | + echo "TEST_ACTION=true" >> $GITHUB_ENV |
| 77 | + fi |
| 78 | +
|
| 79 | + - name: Build |
| 80 | + id: build-plugin |
| 81 | + run: | |
| 82 | + bash .github/build |
| 83 | + if [ -d "${{ github.workspace }}/build/${{ env.PLUGIN_SLUG }}" ]; then |
| 84 | + echo "free_exists=true" >> "${GITHUB_OUTPUT}" |
| 85 | + else |
| 86 | + echo "free_exists=false" >> "${GITHUB_OUTPUT}" |
| 87 | + fi |
| 88 | +
|
| 89 | + - name: WordPress Plugin Deploy |
| 90 | + if: steps.build-plugin.outputs.free_exists == 'true' |
| 91 | + id: deploy |
| 92 | + uses: 10up/action-wordpress-plugin-deploy@stable |
| 93 | + with: |
| 94 | + generate-zip: true |
| 95 | + dry-run: ${{ env.TEST_ACTION }} |
| 96 | + env: |
| 97 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 98 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 99 | + BUILD_DIR: "${{ github.workspace }}/build/${{ env.PLUGIN_SLUG }}" |
| 100 | + SLUG: ${{ env.PLUGIN_SLUG }} |
| 101 | + - name: Upload release asset |
| 102 | + if: steps.build-plugin.outputs.free_exists == 'true' |
| 103 | + uses: softprops/action-gh-release@v2 |
| 104 | + env: |
| 105 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + with: |
| 107 | + files: ${{ steps.deploy.outputs['zip-path'] }} |
0 commit comments