|
| 1 | +name: Build and deploy user guide to Drupalize.Me/Pantheon. |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - drupalizeme_live |
| 7 | + paths: |
| 8 | + - "source/en/**" |
| 9 | + - "scripts/**" |
| 10 | + - ".ddev/**" |
| 11 | + - ".github/workflows/deploy-user-guide.yml" |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +env: |
| 15 | + SITE: dmetng |
| 16 | + ENV: dev |
| 17 | + SITE_ID: 63420aa4-ce06-4c3f-8f75-4d55c57437e6 |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + name: Build English HTML |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Check out code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Setup DDEV |
| 31 | + uses: ddev/github-action-setup-ddev@v1 |
| 32 | + with: |
| 33 | + autostart: true |
| 34 | + |
| 35 | + - name: Build HTML feed for English |
| 36 | + run: | |
| 37 | + echo "en" > scripts/languages.txt |
| 38 | + ddev exec bash -lc 'cd /var/www/html/scripts && bash -ex mkfeeds.sh' |
| 39 | +
|
| 40 | + - name: Generate tutorial changed-dates CSV |
| 41 | + run: | |
| 42 | + mkdir -p ./output/html_feed/en |
| 43 | + rm -f ./output/html_feed/en/tutorial-changed-dates.csv |
| 44 | +
|
| 45 | + git ls-files -- source/en/*.asciidoc | |
| 46 | + while read -r file; do |
| 47 | + timestamp=$(git log --pretty=format:%ct -1 -- "$file") |
| 48 | + mapped=$(echo "$file" | sed 's|^source/en||' | sed 's|\.asciidoc$|.html|') |
| 49 | + echo "$mapped,$timestamp" >> ./output/html_feed/en/tutorial-changed-dates.csv |
| 50 | + done |
| 51 | +
|
| 52 | + test -f ./output/html_feed/en/guide.docbook |
| 53 | + test -f ./output/html_feed/en/tutorial-changed-dates.csv |
| 54 | + test -f ./user_guide_video_map.csv |
| 55 | +
|
| 56 | + - name: Upload build artifact |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: user-guide-html-feed-en |
| 60 | + if-no-files-found: error |
| 61 | + path: | |
| 62 | + output/html_feed/en |
| 63 | + user_guide_video_map.csv |
| 64 | +
|
| 65 | + deploy: |
| 66 | + if: false |
| 67 | + name: Sync and import on Pantheon |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: build |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Check out code |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Download build artifact |
| 76 | + uses: actions/download-artifact@v4 |
| 77 | + with: |
| 78 | + name: user-guide-html-feed-en |
| 79 | + path: . |
| 80 | + |
| 81 | + - name: Set up SSH |
| 82 | + uses: shimataro/ssh-key-action@v2 |
| 83 | + with: |
| 84 | + key: ${{ secrets.PANTHEON_SSH_KEY }} |
| 85 | + known_hosts: unnecessary |
| 86 | + config: | |
| 87 | + Host *.drush.in |
| 88 | + StrictHostKeyChecking no |
| 89 | + Port 2222 |
| 90 | + ServerAliveInterval 60 |
| 91 | + ServerAliveCountMax 10 |
| 92 | +
|
| 93 | + - name: Install Terminus |
| 94 | + uses: pantheon-systems/terminus-github-actions@v1 |
| 95 | + with: |
| 96 | + pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} |
| 97 | + |
| 98 | + - name: Rsync user guide files to Pantheon |
| 99 | + run: | |
| 100 | + rsync -rlvz --ipv4 --progress -e 'ssh -p 2222' output/html_feed/en/* --temp-dir=../../../tmp/ "${{ env.ENV }}.${{ env.SITE_ID }}@appserver.${{ env.ENV }}.${{ env.SITE_ID }}.drush.in:files/private/user_guide/" |
| 101 | + rsync -rlvz --ipv4 --progress -e 'ssh -p 2222' user_guide_video_map.csv --temp-dir=../../../tmp/ "${{ env.ENV }}.${{ env.SITE_ID }}@appserver.${{ env.ENV }}.${{ env.SITE_ID }}.drush.in:files/private/user_guide/" |
| 102 | +
|
| 103 | + - name: Run Drupal migrations |
| 104 | + run: | |
| 105 | + terminus remote:drush "${{ env.SITE }}.${{ env.ENV }}" -- config:import --partial --source=modules/custom/dme_import/config/install/ --yes |
| 106 | + terminus remote:drush "${{ env.SITE }}.${{ env.ENV }}" -- migrate-import user_guide_files --yes --update |
| 107 | + terminus remote:drush "${{ env.SITE }}.${{ env.ENV }}" -- migrate-import user_guide_media_entities --yes --update |
| 108 | + terminus remote:drush "${{ env.SITE }}.${{ env.ENV }}" -- migrate-import user_guide_chapters --yes --update |
| 109 | + terminus remote:drush "${{ env.SITE }}.${{ env.ENV }}" -- migrate-import user_guide_tutorials --yes --update |
| 110 | + terminus remote:drush "${{ env.SITE }}.${{ env.ENV }}" -- cr --yes |
0 commit comments