Created
June 29, 2022 12:50
-
-
Save chadwcarlson/fd77438a95a6cfa93fbbaa5c56a5769c to your computer and use it in GitHub Desktop.
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
deploy: | |
name: 'Deploy to Platform.sh' | |
needs: [build-frontend, coder, install] | |
runs-on: ubuntu-latest | |
# Deploy to Platform.sh only for branches. | |
if: ${{ github.event_name == 'push' }} | |
env: | |
GITHUB_REF: ${{ github.event.ref }} | |
steps: | |
- name: Extract branch name | |
id: branch-name | |
run: echo "::set-output name=branch::${GITHUB_REF:11}" | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ steps.branch-name.outputs.branch }} | |
fetch-depth: 0 | |
- name: Get the HEAD commit of the branch. | |
id: head-ref | |
run: echo "::set-output name=ref::$(git rev-parse origin/${GITHUB_REF:11})" | |
- name: Set up SSH keys and known hosts | |
if : ${{ github.sha == steps.head-ref.outputs.ref }} | |
env: | |
SSH_HOSTKEYS: ${{ secrets.SSH_HOSTKEYS_PLATFORMSH }} | |
SSH_KEY: ${{ secrets.SSH_KEY_PLATFORMSH }} | |
run: | | |
mkdir -p ~/.ssh | |
chmod 0700 ~/.ssh | |
touch ~/.ssh/known_hosts | |
chmod 644 ~/.ssh/known_hosts | |
echo "$SSH_HOSTKEYS" >> ~/.ssh/known_hosts | |
echo "$SSH_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
- name: Add the Platform.sh remote | |
if : ${{ github.sha == steps.head-ref.outputs.ref }} | |
run: | |
git remote add platformsh zw7vyiqte44g2@git.uk-1.platform.sh:zw7vyiqte44g2.git | |
- name: Push branch to Platform.sh | |
if : ${{ github.sha == steps.head-ref.outputs.ref }} | |
run: git push platformsh HEAD:refs/heads/${GITHUB_REF:11} --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment