From 33075ceec0eaa5fbd4f09a43d3162c137f2562cd Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 27 Aug 2024 13:53:19 -0400 Subject: [PATCH] Tools: Add build workflow to create build automatically --- .github/workflows/build.yml | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7119c9a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,49 @@ +name: Build files and push to `build` branch. + +on: + push: + branches: + - trunk + paths: + - themes/** + - plugins/** + # Enable manually running action if necessary. + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - name: Setup + uses: WordPress/wporg-repo-tools/.github/actions/setup@trunk + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Remove build artifacts + run: | + rm -rf themes/wporg-5ftf/node_modules themes/wporg-5ftf-2024/node_modules plugins/wporg-5ftf/node_modules + + - name: Ignore .gitignore + run: | + git add themes/wporg-5ftf/* --force + git add themes/wporg-5ftf/* --force + git add plugins/wporg-5ftf/* --force + + - name: Append build number to version + run: | + current_version=$(grep -oP 'Version: \K[0-9]+\.[0-9]+\.[0-9]+' themes/wporg-5ftf-2024/style.css) + new_version="${current_version}-${GITHUB_SHA::7}" + sed -i "s/Version: $current_version/Version: $new_version/" themes/wporg-5ftf-2024/style.css + sed -i "s/\"version\": \"0.1.0\"/\"version\": \"$new_version\"/" themes/wporg-5ftf-2024/build/**/block.json + + - name: Commit and push + # Using a specific hash here instead of a tagged version, for risk mitigation, since this action modifies our repo. + uses: actions-js/push@a52398fac807b0c1e5f1492c969b477c8560a0ba # 1.3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: build + force: true + message: 'Build: ${{ github.sha }}'