File tree Expand file tree Collapse file tree 3 files changed +113
-22
lines changed
Expand file tree Collapse file tree 3 files changed +113
-22
lines changed Original file line number Diff line number Diff line change 1+ name : Build Application
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ env_file :
7+ required : false
8+ type : boolean
9+ default : false
10+ secrets :
11+ DUBBING_API_BASE_URL :
12+ required : false
13+ TRANSCRIPTION_API_BASE_URL :
14+ required : false
15+ MATXA_API_BASE_URL :
16+ required : false
17+
18+ jobs :
19+ build :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - uses : actions/checkout@v4
23+
24+ - name : Use Node.js
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : " 18"
28+
29+ - name : Install dependencies
30+ run : npm ci
31+
32+ - name : Load .env.production
33+ if : inputs.env_file
34+ run : |
35+ echo "DUBBING_API_BASE_URL=$(grep DUBBING_API_BASE_URL .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
36+ echo "TRANSCRIPTION_API_BASE_URL=$(grep TRANSCRIPTION_API_BASE_URL .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
37+ echo "MATXA_API_BASE_URL=$(grep MATXA_API_BASE_URL .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
38+ echo "APP_MODE=$(grep APP_MODE .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
39+ echo "APP_LANGUAGE=$(grep APP_LANGUAGE .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
40+
41+ - name : Build
42+ run : npm run build:prod
43+ env :
44+ DUBBING_API_BASE_URL : ${{ inputs.env_file && env.DUBBING_API_BASE_URL || secrets.DUBBING_API_BASE_URL }}
45+ TRANSCRIPTION_API_BASE_URL : ${{ inputs.env_file && env.TRANSCRIPTION_API_BASE_URL || secrets.TRANSCRIPTION_API_BASE_URL }}
46+ MATXA_API_BASE_URL : ${{ inputs.env_file && env.MATXA_API_BASE_URL || secrets.MATXA_API_BASE_URL }}
47+ APP_MODE : ${{ inputs.env_file && env.APP_MODE || 'production' }}
48+ APP_LANGUAGE : ${{ inputs.env_file && env.APP_LANGUAGE || 'ca' }}
49+
50+ - name : Upload build artifacts
51+ uses : actions/upload-artifact@v4
52+ with :
53+ name : dist
54+ path : dist/
Original file line number Diff line number Diff line change 99 - main
1010
1111jobs :
12- build-and-deploy :
12+ build :
13+ uses : ./.github/workflows/build.yml
14+ with :
15+ env_file : true
16+
17+ deploy :
18+ needs : build
1319 runs-on : ubuntu-latest
1420 if : ${{ github.event.workflow_run.conclusion == 'success' }}
1521 steps :
16- - uses : actions/checkout@v4
17- - name : Use Node.js
18- uses : actions/setup-node@v4
22+ - name : Download build artifacts
23+ uses : actions/download-artifact@v4
1924 with :
20- node-version : " 18"
21- - name : Install dependencies
22- run : npm ci
23- - name : Load .env.production
24- run : |
25- echo "DUBBING_API_BASE_URL=$(grep DUBBING_API_BASE_URL .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
26- echo "TRANSCRIPTION_API_BASE_URL=$(grep TRANSCRIPTION_API_BASE_URL .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
27- echo "MATXA_API_BASE_URL=$(grep MATXA_API_BASE_URL .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
28- echo "APP_MODE=$(grep APP_MODE .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
29- echo "APP_LANGUAGE=$(grep APP_LANGUAGE .env.production | cut -d '=' -f2)" >> $GITHUB_ENV
30- - name : Build
31- run : npm run build:prod
32- env :
33- DUBBING_API_BASE_URL : ${{ env.DUBBING_API_BASE_URL }}
34- TRANSCRIPTION_API_BASE_URL : ${{ env.TRANSCRIPTION_API_BASE_URL }}
35- MATXA_API_BASE_URL : ${{ env.MATXA_API_BASE_URL }}
36- APP_MODE : ${{ env.APP_MODE }}
37- APP_LANGUAGE : ${{ env.APP_LANGUAGE }}
25+ name : dist
26+ path : dist
27+
3828 - name : Deploy to GitHub Pages
3929 uses : peaceiris/actions-gh-pages@v4
4030 with :
Original file line number Diff line number Diff line change 1+ name : Sync to WordPress Theme
2+
3+ on :
4+ release :
5+ types : [published]
6+
7+ jobs :
8+ build :
9+ uses : ./.github/workflows/build.yml
10+ secrets :
11+ DUBBING_API_BASE_URL : ${{ secrets.DUBBING_API_BASE_URL }}
12+ TRANSCRIPTION_API_BASE_URL : ${{ secrets.TRANSCRIPTION_API_BASE_URL }}
13+ MATXA_API_BASE_URL : ${{ secrets.MATXA_API_BASE_URL }}
14+
15+ sync :
16+ needs : build
17+ runs-on : ubuntu-latest
18+ steps :
19+ - name : Download build artifacts
20+ uses : actions/download-artifact@v4
21+ with :
22+ name : dist
23+ path : dist
24+
25+ - name : Find JS filename
26+ id : find-js
27+ run : |
28+ JS_FILE=$(find dist/assets -name "index-*.js" -type f)
29+ echo "js_file=$JS_FILE" >> $GITHUB_OUTPUT
30+
31+ - name : Checkout wp-softcatala repository
32+ uses : actions/checkout@v4
33+ with :
34+ repository : Softcatala/wp-softcatala
35+ token : ${{ secrets.WP_REPO_TOKEN }}
36+
37+ - name : Copy JS file
38+ run : |
39+ cp ${{ steps.find-js.outputs.js_file }} static/js/subdub-editor.js
40+
41+ - name : Commit and push changes
42+ run : |
43+ git config --global user.name 'github-actions[bot]'
44+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
45+ git add static/js/subdub-editor.js
46+ git commit -m "Update subdub-editor.js to version ${{ github.event.release.tag_name }}"
47+ git push origin HEAD:master
You can’t perform that action at this time.
0 commit comments