|
| 1 | +name: Update gh-pages dependency and push |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master", "main"] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + update-gh-pages: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout current branch |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Read current package version |
| 20 | + id: read_version |
| 21 | + run: | |
| 22 | + # Use node to print the version only, capture it safely into a shell var and write to GITHUB_OUTPUT |
| 23 | + ver=$(node -e "process.stdout.write(require('./package.json').version)") |
| 24 | + echo "PACKAGE_VERSION=$ver" >> $GITHUB_OUTPUT |
| 25 | +
|
| 26 | + - name: "Debug: show package version" |
| 27 | + run: | |
| 28 | + echo "Read package version: ${{ steps.read_version.outputs.PACKAGE_VERSION }}" |
| 29 | +
|
| 30 | + - name: Configure git |
| 31 | + run: | |
| 32 | + git config user.name "github-actions[bot]" |
| 33 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 34 | +
|
| 35 | + - name: Fetch gh-pages branch |
| 36 | + run: | |
| 37 | + git fetch origin gh-pages:gh-pages || git checkout --orphan gh-pages |
| 38 | +
|
| 39 | + - name: Switch to gh-pages |
| 40 | + run: | |
| 41 | + git checkout gh-pages || git checkout --orphan gh-pages |
| 42 | +
|
| 43 | + - name: Update dependency version in gh-pages package.json |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + echo "Updating or creating package.json with emoji-picker-react@${{ steps.read_version.outputs.PACKAGE_VERSION }}" |
| 47 | + PACKAGE_VERSION='${{ steps.read_version.outputs.PACKAGE_VERSION }}' node .github/scripts/update-gh-pages-package.js |
| 48 | +
|
| 49 | + - name: Install dependencies |
| 50 | + run: npm ci --legacy-peer-deps || npm install --no-audit --no-fund |
| 51 | + |
| 52 | + - name: Commit version bump |
| 53 | + run: | |
| 54 | + git add package.json || true |
| 55 | + if git diff --staged --quiet; then |
| 56 | + echo "No changes to commit" |
| 57 | + else |
| 58 | + git commit -m "chore(gh-pages): update emoji-picker-react to ${{ steps.read_version.outputs.PACKAGE_VERSION }}" |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Push gh-pages |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + run: | |
| 65 | + git push origin gh-pages |
0 commit comments