Another approach

This commit is contained in:
zandercymatics 2023-11-24 12:44:18 -07:00
parent 9c05dcde44
commit 90282c7cdc
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 19 additions and 23 deletions

View file

@ -7,7 +7,7 @@ on:
inputs: inputs:
environment: environment:
type: choice type: choice
description: Which environment do you wish load reports for? description: Which environment load reports for?
options: options:
- stable - stable
- staging - staging
@ -59,31 +59,29 @@ jobs:
upload-reports: upload-reports:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [variables, wait-for-deploy] env:
CF_USERNAME: CF_{{ needs.variables.outputs.environment }}_USERNAME
CF_PASSWORD: CF_{{ needs.variables.outputs.environment }}_PASSWORD
steps: steps:
- uses: actions/checkout@v3
- name: Install CF CLI
run: |
curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&source=github" | tar -zx
sudo mv cf /usr/local/bin
- name: Generate current-federal.csv - name: Generate current-federal.csv
run: | uses: 18f/cg-deploy-action@main
cf api https://api.fr.cloud.gov with:
cf auth ${{ secrets[env.CF_USERNAME] }} ${{ secrets[env.CF_PASSWORD] }} cf_username: ${{ secrets[env.CF_USERNAME] }}
cf target -o cisa-dotgov -s ${{ env.ENVIRONMENT }} cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf ssh getgov-${{ env.ENVIRONMENT }} -c "/tmp/lifecycle/shell -c './manage.py generate_current_federal_report'" cf_org: cisa-dotgov
env: cf_space: ${{ needs.variables.outputs.environment }}
ENVIRONMENT: ${{ needs.variables.outputs.environment }} full_command: "cf run-task getgov-${{ needs.variables.outputs.environment }} --command 'python manage.py generate_current_federal_report' --name federal"
CF_USERNAME: CF_${{ needs.variables.outputs.environment }}_USERNAME
CF_PASSWORD: CF_${{ needs.variables.outputs.environment }}_PASSWORD
- name: Generate current-full.csv - name: Generate current-full.csv
run: cf run-task getgov-${{ env.ENVIRONMENT }} "/tmp/lifecycle/shell -c './manage.py generate_current_full_report'" uses: 18f/cg-deploy-action@main
env: with:
ENVIRONMENT: ${{ needs.variables.outputs.environment }} cf_username: ${{ secrets[env.CF_USERNAME] }}
cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf_org: cisa-dotgov
cf_space: ${{ needs.variables.outputs.environment }}
full_command: "cf run-task getgov-${{ needs.variables.outputs.environment }} --command 'python manage.py generate_current_full_report' --name full"
comment: comment:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [variables, upload-reports] needs: [variables, upload-reports]

View file

@ -3,7 +3,6 @@ import os
from django.apps import apps from django.apps import apps
from django.views.decorators.http import require_http_methods from django.views.decorators.http import require_http_methods
from django.http import FileResponse, HttpResponse, JsonResponse from django.http import FileResponse, HttpResponse, JsonResponse
import requests import requests
from login_required import login_not_required from login_required import login_not_required
@ -107,7 +106,6 @@ def get_current_federal(request):
file_path = "migrationdata/current-federal.csv" file_path = "migrationdata/current-federal.csv"
return serve_file(file_path) return serve_file(file_path)
def serve_file(file_path): def serve_file(file_path):
"""Downloads a file based on a given filepath. Returns a 404 if not found.""" """Downloads a file based on a given filepath. Returns a 404 if not found."""
if os.path.exists(file_path): if os.path.exists(file_path):