File tree Expand file tree Collapse file tree 4 files changed +81
-1
lines changed
Expand file tree Collapse file tree 4 files changed +81
-1
lines changed Original file line number Diff line number Diff line change 1+ FROM wordpress:cli
2+
3+ USER root
4+ RUN apk add --no-cache git
5+
6+ COPY entrypoint.sh /entrypoint.sh
7+
8+ ENTRYPOINT ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change 1- # action-wordpress- pot-generator
1+ # WordPress . pot File Generator - Github Action
22Generates .pot file for your WordPress plugin or theme repository
Original file line number Diff line number Diff line change 1+ name : ' WordPress .pot File Generator'
2+ description : ' Generates .pot file for your WordPress plugin or theme repository'
3+ author : ' iamdharmesh'
4+ inputs :
5+ destination_path :
6+ description : ' Destination path to save generated .pot file'
7+ default : ' ./languages'
8+ required : false
9+ slug :
10+ description : ' Plugin or theme slug. Defaults to the Github repository name.'
11+ required : false
12+ text_domain :
13+ description : ' Text domain to look for in the source code. Defaults to the plugin or theme slug.'
14+ required : false
15+ runs :
16+ using : ' docker'
17+ image : ' Dockerfile'
18+ args :
19+ - ${{ inputs.destination_path }}
20+ - ${{ inputs.slug }}
21+ - ${{ inputs.text_domain }}
22+ branding :
23+ icon : ' file-text'
24+ color : ' blue'
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ # Set options based on user input
5+ if [ -z " $INPUT_DESTINATION_PATH " ]; then
6+ DESTINATION_PATH=" ./languages"
7+ else
8+ DESTINATION_PATH=$INPUT_DESTINATION_PATH
9+ fi
10+
11+ if [ -z " $INPUT_SLUG " ]; then
12+ SLUG=${GITHUB_REPOSITORY#*/ }
13+ else
14+ SLUG=$INPUT_SLUG
15+ fi
16+
17+ if [ -z " $INPUT_TEXT_DOMAIN " ]; then
18+ TEXT_DOMAIN=$SLUG
19+ else
20+ TEXT_DOMAIN=$INPUT_TEXT_DOMAIN
21+ fi
22+
23+ POT_PATH=" $DESTINATION_PATH /$TEXT_DOMAIN .pot"
24+ echo " ✔️ DESTINATION_PATH: $DESTINATION_PATH "
25+ echo " ✔️ SLUG : $SLUG "
26+ echo " ✔️ TEXT_DOMAIN: $TEXT_DOMAIN "
27+
28+ if [ ! -d " $DESTINATION_PATH " ]; then
29+ mkdir -p $DESTINATION_PATH
30+ fi
31+
32+ # Generate POT file.
33+ echo " 🔨 Generating POT file"
34+ wp i18n make-pot . " $POT_PATH " --domain=" $TEXT_DOMAIN " --slug=" $SLUG " --allow-root --color
35+
36+
37+ # Setup Git config and push .pot file to github repo
38+ git config --global user.name " WordPress .pot File Generator"
39+ git config --global user.email " wpghactionbot@gmail.com"
40+
41+ if [ " $( git status $POT_PATH --porcelain) " != " " ]; then
42+ echo " 🔼 Pushing to repository"
43+ git add " $POT_PATH "
44+ git commit -m " 🔄 Generated POT File"
45+ git push " https://x-access-token:$GITHUB_TOKEN @github.com/$GITHUB_REPOSITORY "
46+ else
47+ echo " ☑️ No changes are required to .pot file"
48+ fi
You can’t perform that action at this time.
0 commit comments