diff --git a/.github/workflows/general.yaml b/.github/workflows/general.yaml new file mode 100644 index 00000000..a3d5d6d5 --- /dev/null +++ b/.github/workflows/general.yaml @@ -0,0 +1,69 @@ +name: Development Builder +on: + push: + branches: + - 'main' + pull_request: + types: + - opened + - reopened + - synchronize + - edited + - auto_merge_enabled + - auto_merge_disabled + - closed + branches: + - 'main' + +permissions: + actions: write + contents: write + id-token: write + +concurrency: + group: "documentation" + cancel-in-progress: false + +defaults: + run: + shell: bash + +jobs: + build-test: + runs-on: ubuntu-latest + steps: + - name: "Checkout Repository" + uses: actions/checkout@v4 + - name: "Prepare Documentation Builder" + run: | + ./doc-builder build-image + - name: "Build Documentation Test" + run: | + ./doc-builder update-repositories + ./doc-builder build + dev-deployment: + if: ${{ github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + needs: build-test + steps: + - name: "Checkout Repository" + uses: actions/checkout@v4 + with: + token: '${{ github.token }}' + - name: "Prepare Documentation Builder" + run: | + ./doc-builder build-image + - name: "Prepare Documentation Dev Deployment" + run: | + sed -i -r "s|(site_url: .*)|\1dev/|g" ./mkdocs.yml + cat ./mkdocs.yml + ./doc-builder update-repositories + ./doc-builder build + - name: "Upload Documentation" + uses: SamKirkland/FTP-Deploy-Action@v4.3.5 + with: + server: ${{ secrets.ftp_server }} + username: ${{ secrets.ftp_username }} + password: ${{ secrets.ftp_password }} + server-dir: /dev/ + local-dir: ./site/ diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 00000000..e8d07ff2 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,90 @@ +name: Pull Request Builder +on: + pull_request: + types: + - opened + - reopened + - synchronize + - edited + - auto_merge_enabled + - auto_merge_disabled + - closed + branches: + - 'main' + +permissions: + actions: write + contents: write + id-token: write + pull-requests: write + +concurrency: + group: "documentation" + cancel-in-progress: false + +defaults: + run: + shell: bash + +jobs: + build-deploy-pr: + if: github.event.action != 'closed' + runs-on: ubuntu-latest + steps: + - name: "Checkout Repository" + uses: actions/checkout@v4 + - name: "Prepare Documentation Builder" + run: | + ./doc-builder build-image + - name: "Build Documentation" + run: | + ./doc-builder update-repositories + ./doc-builder build + - name: "Creating Deployment Artifact" + run: | + mv site "${{ github.head_ref }}" + ls -lah + zip -r "${{ github.head_ref }}.zip" . -i "${{ github.head_ref }}/*" + - name: "Uploading Pull Request Deployment" + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.ssh_server }} + port: ${{ secrets.ssh_port }} + username: ${{ secrets.ssh_username }} + key: ${{ secrets.ssh_key }} + source: "${{ github.head_ref }}.zip" + target: . + - name: "Deploying Pull Request Deployment" + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ secrets.ssh_server }} + port: ${{ secrets.ssh_port }} + username: ${{ secrets.ssh_username }} + key: ${{ secrets.ssh_key }} + script: | + ./pull_request_helper.sh deploy ${{ github.head_ref }} + - name: Add Pull Request Deployment Comment" + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '🤖: Deployment available as https://docstest.simplyblock.io/${{ github.head_ref }}' + }) + + remove-closed-pr: + if: github.event.action == 'closed' + runs-on: ubuntu-latest + steps: + - name: "Removing Pull Request Deployment" + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ secrets.ssh_server }} + port: ${{ secrets.ssh_port }} + username: ${{ secrets.ssh_username }} + key: ${{ secrets.ssh_key }} + script: | + ./pull_request_helper.sh remove ${{ github.head_ref }} diff --git a/.github/workflows/mkdocs.yaml b/.github/workflows/release.yaml similarity index 57% rename from .github/workflows/mkdocs.yaml rename to .github/workflows/release.yaml index 8753752a..1601a384 100644 --- a/.github/workflows/mkdocs.yaml +++ b/.github/workflows/release.yaml @@ -1,19 +1,8 @@ -name: Build or Deploy Simplyblock Documentation +name: Release Builder on: push: branches: - - 'main' - 'release/**' - pull_request: - types: - - opened - - reopened - - synchronize - - edited - - auto_merge_enabled - - auto_merge_disabled - branches: - - 'main' permissions: actions: write @@ -29,47 +18,7 @@ defaults: shell: bash jobs: - build-test: - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - runs-on: ubuntu-latest - steps: - - name: "Checkout Repository" - uses: actions/checkout@v4 - - name: "Prepare Documentation Builder" - run: | - ./doc-builder build-image - - name: "Build Documentation Test" - run: | - ./doc-builder update-repositories - ./doc-builder build - dev-deployment: - if: ${{ github.ref == 'refs/heads/main' }} - runs-on: ubuntu-latest - needs: build-test - steps: - - name: "Checkout Repository" - uses: actions/checkout@v4 - with: - token: '${{ github.token }}' - - name: "Prepare Documentation Builder" - run: | - ./doc-builder build-image - - name: "Prepare Documentation Dev Deployment" - run: | - sed -i -r "s|(site_url: .*)|\1dev/|g" ./mkdocs.yml - cat ./mkdocs.yml - ./doc-builder update-repositories - ./doc-builder build - - name: "Upload Documentation" - uses: SamKirkland/FTP-Deploy-Action@v4.3.5 - with: - server: ${{ secrets.ftp_server }} - username: ${{ secrets.ftp_username }} - password: ${{ secrets.ftp_password }} - server-dir: /dev/ - local-dir: ./site/ deployment: - if: ${{ startsWith(github.ref, 'refs/heads/release/') }} runs-on: ubuntu-latest steps: - name: "Checkout Repository" @@ -120,7 +69,7 @@ jobs: uses: mtanzi/action-automerge@v1 with: github_token: "${{ github.token }}" - source: "refs/tags/${{ env.RELEASE_NAME }}" + source: ${{ github.ref_name }} target: "main" webhook_url: "" - name: "Remove Release Branch"