Aam-Digital/ndb-core

View on GitHub
.github/workflows/pull-request-opened.yml

Summary

Maintainability
Test Coverage
name: Pull Request - Set Up

permissions:
  pull-requests: write

on:
  pull_request:
    types: [opened, reopened]

jobs:
  create-deployment:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository files
        uses: actions/checkout@v4

      - name: Prepare server deployment
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USERNAME }}
          key: ${{ secrets.SSH_KEY }}
          script: |
            cd /var/docker
            cp -r x-pr pr-${{ github.event.number }}
            sed -i "s/<PR_NUMBER>/${{ github.event.number }}/g" pr-${{ github.event.number }}/docker-compose.yml

      - name: Post comment on PR
        run: |
          curl -X POST \
          -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
          -H "Accept: application/vnd.github.v3+json" \
          https://api.github.com/repos/Aam-Digital/ndb-core/issues/${{ github.event.number }}/comments \
          -d '{"body":"Deployed to https://pr-${{ github.event.number }}.aam-digital.net/"}'