Add workflow for deploying to staging

This commit is contained in:
Matt-Yorkley
2023-06-15 19:37:18 +01:00
parent 7068df5d4b
commit 12bf17e21e

32
.github/workflows/stage.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: "Deploy to Staging"
on:
pull_request:
types: [labeled]
permissions:
contents: read
jobs:
deploy:
if: contains(fromJSON('["pr-staged-uk", "pr-staged-au", "pr-staged-fr"]'), github.event.label.name)
runs-on: ubuntu-latest
steps:
- name: Configure deployment key
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.DEPLOYMENT_KEY }}" > ~/.ssh/id_rsa
echo "${{ secrets.DEPLOYMENT_HOSTS }}" > ~/.ssh/known_hosts
- name: Deploy to Staging
env:
BRANCH_NAME: pull-request-${{ github.event.pull_request.number }}
LABEL: ${{ github.event.label.name }}
run: |
if [[ $LABEL == 'pr-staged-uk' ]]; then
ssh ofn-deploy@staging.openfoodnetwork.org.uk -o LogLevel=ERROR "$BRANCH_NAME"
elif [[ $LABEL == 'pr-staged-au' ]]; then
ssh ofn-deploy@staging.openfoodnetwork.org.au -o LogLevel=ERROR "$BRANCH_NAME"
elif [[ $LABEL == 'pr-staged-fr' ]]; then
ssh ofn-deploy@staging.coopcircuits.fr -o LogLevel=ERROR "$BRANCH_NAME"
fi