Replacing references to squid with staging #565
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Web Previews | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- preview-** | |
workflow_call: | |
inputs: | |
branch: | |
required: true | |
type: string | |
jobs: | |
Deploy-Web-Preview: | |
if: ${{ github.repository_owner == 'CHTC' }} | |
runs-on: ubuntu-latest | |
env: | |
preview_url: https://github.com/CHTC/web-preview.git | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: 'recursive' | |
ref: ${{ inputs.branch }} | |
- name: Get branch name | |
run: echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.6 | |
bundler-cache: true | |
- name: Configure for Dev Preview | |
run: | | |
rm CNAME -f | |
sed -i "s|baseurl: ''|baseurl: '/web-preview/${{ env.BRANCH_NAME }}'|" _config.yml | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git commit -am "GHA: path-cc/path-cc.github.io #$GITHUB_RUN_NUMBER" | |
- name: Setup SSH Keys and known_hosts | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.WEB_PREVIEW_DEPLOY_KEY }} | |
- name: Build Website | |
run: | | |
git checkout -b temp-branch | |
bundle exec jekyll build | |
- uses: CHTC/search_index_build@master | |
with: | |
parameter_file_path: .search-bar.json | |
- name: Deploy | |
run: | | |
mkdir temp-dir | |
mv _site ${{ env.BRANCH_NAME }} | |
mv ${{ env.BRANCH_NAME }} temp-dir | |
git add temp-dir | |
git commit -m "Build Branch Website" | |
SPLIT_BRANCH=$(git subtree split --prefix temp-dir temp-branch) | |
git remote add web-preview ${{ env.preview_url }} | |
git fetch web-preview | |
git checkout -b preview web-preview/main | |
git merge $SPLIT_BRANCH -m "Merge Split Branch" --allow-unrelated-histories -X theirs | |
git push web-preview HEAD:main | |
- name: Print the preview url | |
run: | | |
echo "Your Preview URL: https://chtc.github.io/web-preview/${{ env.BRANCH_NAME }}/" |