Skip to content

Commit 1ca7f75

Browse files
authored
Fix stuff (#3)
* add readme.md * allow a gh token to be passed to the action * remove unused action stuff * add logging and move stuff around * add debugging information * add shell * fix duplicate md check * remove unused variable * re-add stuff that wasn't in phil's pr
1 parent 8f9d62d commit 1ca7f75

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Plugin Test
2+
Contributors: jazzsequence
3+
Tags: github actions, testing
4+
Requires at least: 5.8
5+
Tested up to: 6.6.1
6+
Stable tag: 1.0.0
7+
License: MIT
8+
License URI: https://opensource.org/licenses/MIT
9+
10+
This is a test plugin for testing GitHub Actions workflows.

action.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,27 @@ inputs:
1313
description: Whether to actually commit the changes to the repository.
1414
required: false
1515
default: false
16+
gh-token:
17+
description: The GitHub token to use for creating a pull request.
18+
required: false
19+
default: ${{ github.token }}
1620
runs:
1721
using: composite
1822
steps:
1923
- uses: actions/checkout@v4
24+
- name: Debug Action Environment
25+
shell: bash
26+
run: |
27+
echo "Current working directory:"
28+
pwd
29+
echo "Contents of action directory (looking for bin/validate-plugin-version.sh):"
30+
ls -R
2031
- name: Validate Plugin Tested Up To Version
2132
shell: bash
2233
env:
2334
PLUGIN_PATH: ${{ inputs.plugin-path }}
2435
DRY_RUN: ${{ inputs.dry-run }}
2536
WORKFLOW_PATH: ${{ github.workspace }}
26-
run: bash bin/validate-plugin-version.sh ${{ inputs.plugin-path }}
27-
# - name: Create Pull Request
28-
# if: # something here
29-
# Create a pull request with the changes made from running the script.
37+
GH_TOKEN: ${{ inputs.gh-token }}
38+
run: bash bin/validate-plugin-version.sh
3039

bin/validate-plugin-version.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33
IFS=$'\n\t'
44

5-
main(){
5+
main() {
66
# If $PLUGIN_PATH is defined, echo it.
77
if [[ -n "${PLUGIN_PATH:-}" ]]; then
88
PLUGIN_PATH=${WORKFLOW_PATH}/${PLUGIN_PATH}
@@ -65,21 +65,26 @@ main(){
6565
# Create a pull request with a dynamic branch name
6666
BRANCH_PREFIX="update-tested-up-to-version-"
6767
BRANCH_NAME="$BRANCH_PREFIX$(date +%Y%m%d%H%M%S)"
68+
69+
echo "Checking if a branch with prefix $BRANCH_PREFIX already exists."
6870
if git ls-remote --heads origin | grep -q "$BRANCH_PREFIX"; then
6971
echo "A branch with prefix $BRANCH_PREFIX already exists. Exiting."
7072
exit 1
7173
fi
7274

75+
echo "Creating a new branch $BRANCH_NAME and pushing changes."
76+
git config user.name "github-actions"
77+
git config user.email "[email protected]"
78+
git checkout -b "$BRANCH_NAME"
79+
git add "${PLUGIN_PATH}/readme.txt" "${PLUGIN_PATH}/README.md" || true
80+
7381
# Bail before committing anything if we're dry-running.
7482
if [[ "${DRY_RUN}" == "true" ]]; then
7583
echo "Dry run enabled. Happy testing."
7684
exit 0
7785
fi
7886

79-
git config user.name "github-actions"
80-
git config user.email "[email protected]"
81-
git checkout -b "$BRANCH_NAME"
82-
git add "${PLUGIN_PATH}/readme.txt" "${PLUGIN_PATH}/README.md" || true
87+
echo "Committing changes and pushing to the repository."
8388
git commit -m "Update Tested Up To version to $CURRENT_WP_VERSION"
8489
git push origin "$BRANCH_NAME"
8590

0 commit comments

Comments
 (0)