# This workflow runs on pushes when a pull request is opened under certain branch conventions. name: Build and deploy developer sandbox run-name: Build and deploy developer sandbox for branch ${{ github.head_ref }} on: pull_request: jobs: variables: if: | startsWith(github.head_ref, 'ab/') || startsWith(github.head_ref, 'bl/') || startsWith(github.head_ref, 'rjm/') || startsWith(github.head_ref, 'rb/') || startsWith(github.head_ref, 'ko/') || startsWith(github.head_ref, 'gd/') || startsWith(github.head_ref, 'za/') || startsWith(github.head_ref, 'rh/') || startsWith(github.head_ref, 'nl/') || startsWith(github.head_ref, 'dk/') || startsWith(github.head_ref, 'es/') || startsWith(github.head_ref, 'ky/') || startsWith(github.head_ref, 'backup/') outputs: environment: ${{ steps.var.outputs.environment}} runs-on: "ubuntu-latest" steps: - name: Setting global variables uses: actions/github-script@v6 id: var with: script: | core.setOutput('environment', '${{ github.head_ref }}'.split("/")[0]); deploy: runs-on: ubuntu-latest needs: [variables] steps: - uses: actions/checkout@v3 - name: Compile USWDS assets working-directory: ./src run: | docker compose run node npm install && docker compose run node npx gulp copyAssets && docker compose run node npx gulp compile - name: Collect static assets working-directory: ./src run: docker compose run app python manage.py collectstatic --no-input - name: Deploy to cloud.gov sandbox uses: cloud-gov/cg-cli-tools@main env: ENVIRONMENT: ${{ needs.variables.outputs.environment }} CF_USERNAME: CF_${{ needs.variables.outputs.environment }}_USERNAME CF_PASSWORD: CF_${{ needs.variables.outputs.environment }}_PASSWORD with: cf_username: ${{ secrets[env.CF_USERNAME] }} cf_password: ${{ secrets[env.CF_PASSWORD] }} cf_org: cisa-dotgov cf_space: ${{ env.ENVIRONMENT }} cf_manifest: ops/manifests/manifest-${{ env.ENVIRONMENT }}.yaml comment: runs-on: ubuntu-latest needs: [variables, deploy] steps: - uses: actions/github-script@v6 env: ENVIRONMENT: ${{ needs.variables.outputs.environment }} 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: '🥳 Successfully deployed to developer sandbox **[${{ env.ENVIRONMENT }}](https://getgov-${{ env.ENVIRONMENT }}.app.cloud.gov/)**.' })