Skip to content

Cleanup users without roles #8459

Cleanup users without roles

Cleanup users without roles #8459

name: Heroku Pull Request
on:
pull_request:
types: [opened, synchronize, reopened, closed]
jobs:
heroku-pull-request:
runs-on: ubuntu-latest
env:
HEROKU_APP_NAME: gyr-review-app-${{ github.event.number }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event.action == 'closed' && 1 || 0 }}
ref: ${{ github.event.action != 'closed' && github.head_ref || '' }}
- name: Login to Heroku
uses: akhileshns/heroku-deploy@v3.12.13
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_email: jheath@codeforamerica.org
heroku_app_name: ${{ env.HEROKU_APP_NAME }}
justlogin: true
- name: Clean up unused old heroku apps, including this one if it's being closed
run: .github/remove_old_heroku_review_apps.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Heroku app
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku apps:create ${{ env.HEROKU_APP_NAME }} --org getyourrefund --stack heroku-22
- name: Save app name and PR number as heroku environment variable
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku config:set HEROKU_APP_NAME=${{ env.HEROKU_APP_NAME }} HEROKU_PR_NUMBER=${{ github.event.number }} -a ${{ env.HEROKU_APP_NAME }}
- name: Add nodejs buildpack
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku buildpacks:set --app ${{ env.HEROKU_APP_NAME }} --index 1 heroku/nodejs
- name: Add ruby buildpack
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku buildpacks:set --app ${{ env.HEROKU_APP_NAME }} --index 2 heroku/ruby
- name: Add activestorage-preview buildpack
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku buildpacks:set --app ${{ env.HEROKU_APP_NAME }} --index 3 https://github.com/heroku/heroku-buildpack-activestorage-preview
- name: Add jvm buildpack
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku buildpacks:set --app ${{ env.HEROKU_APP_NAME }} --index 4 heroku/jvm
- name: Add heroku-buildpack-run buildpack
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku buildpacks:set --app ${{ env.HEROKU_APP_NAME }} --index 5 https://github.com/weibeld/heroku-buildpack-run.git
- name: Copy environment variables to Heroku app
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: |
heroku config:set -a ${{ env.HEROKU_APP_NAME }} \
RAILS_ENV=heroku \
RACK_ENV=production \
LOG_LEVEL=info \
RAILS_SERVE_STATIC_FILES=enabled \
RAILS_MASTER_KEY_NEW=${{ secrets.RAILS_MASTER_KEY_NEW }} \
BUNDLE_GITHUB__COM=${{ secrets.BUNDLE_GITHUB__COM }} \
FRAUD_INDICATORS_KEY=${{ secrets.FRAUD_INDICATORS_KEY }} \
HEROKU_DNS_AWS_ACCESS_KEY_ID=${{ secrets.HEROKU_DNS_AWS_ACCESS_KEY_ID }} \
HEROKU_DNS_SECRET_ACCESS_KEY=${{ secrets.HEROKU_DNS_SECRET_ACCESS_KEY }} \
HEROKU_PLATFORM_KEY=${{ secrets.HEROKU_PLATFORM_KEY }}
- name: Create database
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku addons:create heroku-postgresql:mini --app ${{ env.HEROKU_APP_NAME }}
- name: Add Heroku remote
if: github.event.action != 'closed'
run: heroku git:remote --app=${{ env.HEROKU_APP_NAME }}
- name: Disable Reline autocomplete
if: github.event.action != 'closed'
run: |
echo "IRB.conf[:USE_AUTOCOMPLETE] = false" > .irbrc && \
git add .irbrc && \
git config user.name "GitHub Actions" && \
git config user.email "nobody@example.com" && \
git commit -m "Disable Reline autocomplete"
- name: Push to Heroku
if: github.event.action != 'closed'
run: git push heroku ${{ github.head_ref }}:main --force
- name: Setup database
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku run rails heroku:postdeploy
- name: Setup hostnames (GYR, CTC and StateFile)
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku run rails heroku:review_app_setup
- name: Start the worker process
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: heroku ps:scale worker=1 --app=${{ env.HEROKU_APP_NAME }}
- name: Get heroku generated url
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: echo "HEROKU_URL=$(heroku apps:info -s --app ${{ env.HEROKU_APP_NAME }} | grep web_url | cut -d= -f2)" >> $GITHUB_ENV
- name: Add comment to PR
if: github.event.action == 'opened' || github.event.action == 'reopened'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ github.event.number }} --body '[Heroku app](https://dashboard.heroku.com/apps/${{ env.HEROKU_APP_NAME }}): ${{ env.HEROKU_URL }}<br/>View logs: `heroku logs --app ${{ env.HEROKU_APP_NAME }}` (optionally add `--tail`)'