mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 10:59:21 +02:00
Script cleanup / prepare for PR
This commit is contained in:
parent
a188137988
commit
f40e71ca8b
4 changed files with 11 additions and 49 deletions
49
.github/workflows/daily-csv-upload.yaml
vendored
49
.github/workflows/daily-csv-upload.yaml
vendored
|
@ -7,7 +7,7 @@ on:
|
||||||
inputs:
|
inputs:
|
||||||
environment:
|
environment:
|
||||||
type: choice
|
type: choice
|
||||||
description: Which environment load reports for?
|
description: Which environment do you wish to load reports for?
|
||||||
options:
|
options:
|
||||||
- stable
|
- stable
|
||||||
- staging
|
- staging
|
||||||
|
@ -24,9 +24,10 @@ on:
|
||||||
- bl
|
- bl
|
||||||
- rjm
|
- rjm
|
||||||
- dk
|
- dk
|
||||||
schedule:
|
# TODO - uncomment after #1403 is finished
|
||||||
|
#schedule:
|
||||||
# Runs every day at 5 AM UTC.
|
# Runs every day at 5 AM UTC.
|
||||||
- cron: "0 5 * * *"
|
# - cron: "0 5 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
variables:
|
variables:
|
||||||
|
@ -42,31 +43,13 @@ jobs:
|
||||||
const environment = (github && github.event && github.event.inputs) ? github.event.inputs.environment : 'za';
|
const environment = (github && github.event && github.event.inputs) ? github.event.inputs.environment : 'za';
|
||||||
core.setOutput('environment', environment);
|
core.setOutput('environment', environment);
|
||||||
|
|
||||||
wait-for-deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Wait for deploy to complete
|
|
||||||
uses: fountainhead/action-wait-for-check@v1.0.0
|
|
||||||
id: wait-for-deploy
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
checkName: "deploy"
|
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
|
||||||
# the maximum time to wait for the check to complete, in seconds
|
|
||||||
timeoutSeconds: 600
|
|
||||||
# the time to wait between checks, in seconds
|
|
||||||
intervalSeconds: 10
|
|
||||||
|
|
||||||
upload-reports:
|
upload-reports:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [variables, wait-for-deploy]
|
needs: [variables]
|
||||||
env:
|
env:
|
||||||
CF_USERNAME: CF_ZA_USERNAME
|
CF_USERNAME: CF_{{ needs.variables.outputs.environment }}_USERNAME
|
||||||
CF_PASSWORD: CF_ZA_PASSWORD
|
CF_PASSWORD: CF_{{ needs.variables.outputs.environment }}_PASSWORD
|
||||||
steps:
|
steps:
|
||||||
- name: Wait for a few seconds
|
|
||||||
run: sleep 20
|
|
||||||
|
|
||||||
- name: Generate current-federal.csv
|
- name: Generate current-federal.csv
|
||||||
uses: 18f/cg-deploy-action@main
|
uses: 18f/cg-deploy-action@main
|
||||||
with:
|
with:
|
||||||
|
@ -84,20 +67,4 @@ jobs:
|
||||||
cf_org: cisa-dotgov
|
cf_org: cisa-dotgov
|
||||||
cf_space: ${{ needs.variables.outputs.environment }}
|
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"
|
full_command: "cf run-task getgov-${{ needs.variables.outputs.environment }} --command 'python manage.py generate_current_full_report' --name full"
|
||||||
|
|
||||||
comment:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [variables, upload-reports]
|
|
||||||
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 uploaded current-full.csv and current-federal.csv to **[${{ env.ENVIRONMENT }}](https://getgov-${{ env.ENVIRONMENT }}.app.cloud.gov/)**.'
|
|
||||||
})
|
|
||||||
|
|
|
@ -107,6 +107,7 @@ def get_current_federal(request):
|
||||||
|
|
||||||
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."""
|
||||||
|
# TODO - #1403, grab from the S3 instance instead
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
# Serve the CSV file
|
# Serve the CSV file
|
||||||
response = FileResponse(open(file_path, "rb"))
|
response = FileResponse(open(file_path, "rb"))
|
||||||
|
|
|
@ -21,15 +21,12 @@ class Command(BaseCommand):
|
||||||
directory = os.path.join(options.get("directory"), "")
|
directory = os.path.join(options.get("directory"), "")
|
||||||
logger.info("Generating report...")
|
logger.info("Generating report...")
|
||||||
|
|
||||||
# TODO - Delete
|
|
||||||
current_directory = os.getcwd()
|
|
||||||
logger.info(f"Current working directory: {current_directory}")
|
|
||||||
|
|
||||||
self.generate_current_federal_report(directory)
|
self.generate_current_federal_report(directory)
|
||||||
logger.info(f"Success! Created {directory}current-federal.csv")
|
logger.info(f"Success! Created {directory}current-federal.csv")
|
||||||
|
|
||||||
def generate_current_federal_report(self, directory):
|
def generate_current_federal_report(self, directory):
|
||||||
"""Creates a current-full.csv file under the migrationdata/ directory"""
|
"""Creates a current-full.csv file under the migrationdata/ directory"""
|
||||||
|
# TODO - #1403, push to the S3 instance instead
|
||||||
file_path = os.path.join(directory, "current-federal.csv")
|
file_path = os.path.join(directory, "current-federal.csv")
|
||||||
with open(file_path, "w") as file:
|
with open(file_path, "w") as file:
|
||||||
csv_export.export_data_federal_to_csv(file)
|
csv_export.export_data_federal_to_csv(file)
|
||||||
|
|
|
@ -21,15 +21,12 @@ class Command(BaseCommand):
|
||||||
directory = os.path.join(options.get("directory"), "")
|
directory = os.path.join(options.get("directory"), "")
|
||||||
logger.info("Generating report...")
|
logger.info("Generating report...")
|
||||||
|
|
||||||
# TODO - Delete
|
|
||||||
current_directory = os.getcwd()
|
|
||||||
logger.info(f"Current working directory: {current_directory}")
|
|
||||||
|
|
||||||
self.generate_current_full_report(directory)
|
self.generate_current_full_report(directory)
|
||||||
logger.info(f"Success! Created {directory}current-full.csv")
|
logger.info(f"Success! Created {directory}current-full.csv")
|
||||||
|
|
||||||
def generate_current_full_report(self, directory):
|
def generate_current_full_report(self, directory):
|
||||||
"""Creates a current-full.csv file under the migrationdata/ directory"""
|
"""Creates a current-full.csv file under the migrationdata/ directory"""
|
||||||
|
# TODO - #1403, push to the S3 instance instead
|
||||||
file_path = os.path.join(directory, "current-full.csv")
|
file_path = os.path.join(directory, "current-full.csv")
|
||||||
with open(file_path, "w") as file:
|
with open(file_path, "w") as file:
|
||||||
csv_export.export_data_full_to_csv(file)
|
csv_export.export_data_full_to_csv(file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue