diff --git a/.github/workflows/ops.site.deploy.ddev.yml b/.github/workflows/ops.site.deploy.ddev.yml index 71ed6c7..e14e506 100644 --- a/.github/workflows/ops.site.deploy.ddev.yml +++ b/.github/workflows/ops.site.deploy.ddev.yml @@ -92,36 +92,41 @@ jobs: runs-on: ${{ inputs.github_runs_on }} steps: - - name: Hello world - run: | - echo "-----------------------------" - echo "Hello world!" - echo "-----------------------------" - echo "Who am I: $(whoami)" - echo "Hostname: $(hostname -f)" - echo "-----------------------------" - echo "Path: ${{ inputs.git_root }}" - echo "Git Reference: ${{ inputs.git_reference }}" - echo "Git Repository: ${{ inputs.git_repository }}" - echo "Sync Command: ${{ inputs.sync_command }}" - echo "Deploy Command: ${{ inputs.deploy_command }}" - echo "-----------------------------" - - echo "DDEV Config:" - echo "${{ inputs.ddev_config }}" - echo "Project Name: ${{ inputs.ddev_project_name }}" - echo "Project TLD: ${{ inputs.ddev_project_tld }}" - echo "-----------------------------" + + - uses: actions/checkout@v4 + with: + repository: 'jonpugh/goatscripts' + ref: 'v1.1.0' + path: goatscripts - name: Clone code + env: + SUCCESS: "Codebase successfully cloned :computer:" + ERROR: "Git clone failed :x:" + SUMMARY: | + - Repository: ${{ inputs.git_repository }} + - Reference: ${{ inputs.git_reference }} + - Root: ${{ inputs.git_root }} + - Environment: ${{ inputs.github_environment_name }} + - URL: ${{ inputs.github_environment_url }} + - Pull Request: ${{ github.event.pull_request.html_url }} + run: | + export PATH=$GITHUB_WORKSPACE/goatscripts/src:$PATH + echo $PATH if [[ ! -d ${{ inputs.git_root }} ]]; then - git clone ${{ inputs.git_repository }} ${{ inputs.git_root }} + run-with-summary git clone ${{ inputs.git_repository }} ${{ inputs.git_root }} fi cd ${{ inputs.git_root }} git checkout ${{ inputs.git_reference }} - echo ----------------------------- - echo "Cloned code to ${{ inputs.git_root }}" + + SUMMARY="" + + SUCCESS="git status" \ + run-with-summary git status + + SUCCESS="git log" \ + run-with-summary git log -1 start-site: name: Start site @@ -152,27 +157,38 @@ jobs: exit 1 fi + # Install DDEV, if needed. + # This only works for runners by sudo users. Don't run it if ddev is already installed. + - name: Setup DDEV + uses: ddev/github-action-setup-ddev@v1 + if: ${{ env.DDEV_INSTALLED == 'false' }} + with: + autostart: false + - name: Configure DDEV working-directory: ${{ inputs.git_root }}/.ddev run: | + ddev config global --instrumentation-opt-in=false echo "# DDEV Config created by GitHub workflow https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" > ${{ inputs.ddev_config_filename }} echo "name: ${{ inputs.ddev_project_name }}" >> ${{ inputs.ddev_config_filename }} echo "project_tld: ${{ inputs.ddev_project_tld }}" >> ${{ inputs.ddev_config_filename }} echo "${{ inputs.ddev_config }}" >> ${{ inputs.ddev_config_filename }} + echo "$GITHUB_WORKSPACE/goatscripts/src" >> $GITHUB_PATH - # Install DDEV, if needed. - # This only works for runners by sudo users. Don't run it if ddev is already installed. - - name: Setup DDEV - uses: ddev/github-action-setup-ddev@v1 - if: ${{ env.DDEV_INSTALLED == 'false' }} + - uses: actions/checkout@v4 with: - autostart: false - + repository: 'jonpugh/goatscripts' + ref: 'v1.1.0' + path: goatscripts + - name: Start site working-directory: ${{ inputs.git_root }} if: ${{ inputs.run_start_command }} + env: + SUCCESS: "Started DDEV Site :rocket:" + ERROR: "DDEV start failed :x:" run: | - ${{ inputs.start_command }} + run-with-summary ${{ inputs.start_command }} # Import, sync, install, etc. prepare-data: @@ -187,14 +203,30 @@ jobs: steps: + - uses: actions/checkout@v4 + with: + repository: 'jonpugh/goatscripts' + ref: 'main' + path: goatscripts + + - name: Set environment + run: | + echo "$GITHUB_WORKSPACE/goatscripts/src" >> $GITHUB_PATH + - name: Prepare data working-directory: ${{ inputs.git_root }} if: ${{ inputs.run_prepare_command }} + env: + SUCCESS: "Site data preparation successful :rocket:" + ERROR: "Site data preparation failed :x:" run: | - ${{ inputs.prepare_command }} + run-with-summary ${{ inputs.prepare_command }} - name: Deploy command working-directory: ${{ inputs.git_root }} if: ${{ inputs.run_deploy_command }} + env: + SUCCESS: "Deploy successful :rocket:" + ERROR: "Deploy failed :x:" run: | - ${{ inputs.deploy_command }} + run-with-summary ${{ inputs.deploy_command }} diff --git a/.github/workflows/site.preview.yml b/.github/workflows/site.preview.yml index 948661d..2868f04 100644 --- a/.github/workflows/site.preview.yml +++ b/.github/workflows/site.preview.yml @@ -8,7 +8,7 @@ env: concurrency: group: ${{ github.workflow }}-${{ github.event.number }} - cancel-in-progress: true + cancel-in-progress: false jobs: # This emulates a persistent server. The ddev.site.deploy.yml jobs require one. @@ -24,6 +24,7 @@ jobs: # Kick off the runner script over and over until there are no more queued jobs. - name: "Launch runner script." + run: | while [[ $(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq -r '.jobs[] | select(.status=="queued") | .id' | wc -l) -gt 0 ]]; do ./github-runner-starter \ @@ -31,12 +32,12 @@ jobs: --name=github.actions.runner.${{ github.run_id }}.${{ matrix.runner }} \ --labels=github.actions.runner.${{ github.run_id }} \ --config-sh-options=--ephemeral - sleep 3 + sleep 4 done create-site: name: Create Preview Site - uses: operations-project/github-action-ddev-runner/.github/workflows/ops.site.deploy.ddev.yml@feature/reusable-workflows + uses: operations-project/github-action-ddev-runner/.github/workflows/ops.site.deploy.ddev.yml@feature/run-with-summary with: # Configure your site here. @@ -76,9 +77,23 @@ jobs: needs: create-site runs-on: github.actions.runner.${{ github.run_id }} steps: + + - uses: actions/checkout@v4 + with: + repository: 'jonpugh/goatscripts' + ref: 'main' + path: goatscripts + + - name: Set environment + run: | + echo "$GITHUB_WORKSPACE/goatscripts/src" >> $GITHUB_PATH + - name: Check homepage for Hello World. + env: + SUCCESS: "Tests passed! DDEV webserver is online. :boom:" + ERROR: "Unable to load DDEV website. :x:" run: | - curl -s https://ddev-runner.ddev.site + run-with-summary curl https://ddev-runner.ddev.site curl -s https://ddev-runner.ddev.site | grep "Hello World!" # Not writing ddev config yet. -# curl -s http://pr${{ github.event.number }}.sites.thinkdrop.net \ No newline at end of file +# curl -s http://pr${{ github.event.number }}.sites.thinkdrop.net