File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ name : " Deploy to S3"
2+
3+ on :
4+ push :
5+ branches : [ "**" ]
6+ pull_request :
7+ branches : [ "**" ]
8+ schedule :
9+ - cron : ' 17 14 * * 3'
10+
11+ jobs :
12+ test :
13+ runs-on : ubuntu-latest
14+
15+ strategy :
16+ matrix :
17+ # Run in all these versions of Python
18+ python-version : ["3.10"]
19+
20+ steps :
21+ # Checkout the latest code from the repo
22+ - name : Checkout repo
23+ uses : actions/checkout@v2
24+
25+ # Setup which version of Python to use
26+ - name : Set Up Python ${{ matrix.python-version }}
27+ uses : actions/setup-python@v2
28+ with :
29+ python-version : ${{ matrix.python-version }}
30+
31+ # Display the Python version being used
32+ - name : Display Python version
33+ run : python -c "import sys; print(sys.version)"
34+
35+ # Update pip
36+ - name : Update pip
37+ run : python -m pip install --upgrade pip
38+
39+ # Install requirements.
40+ - name : Install requirements
41+ run : python -m pip install --upgrade -r requirements.txt
42+
43+ # Create environment variables.
44+ - name : Create environment variables
45+ run : python write_config.py --github_access_token ${{ secrets.ACCESS_TOKEN_GITHUB }} --aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --bucket ${{ secrets.AWS_BUCKET }}
46+
47+ # Deploy to S3 Bucket
48+ - name : Deploy to S3
49+ run : python update_voters.py --no_print yes
Original file line number Diff line number Diff line change 11import requests
22import json
33import boto3
4+ import argparse
5+ import sys , os
46from configparser import ConfigParser
57
8+ parser = argparse .ArgumentParser ()
9+ parser .add_argument ("--no_print" , help = "Disable printing" )
10+ args = parser .parse_args ()
11+
12+ if args .no_print :
13+ sys .stdout = open (os .devnull , "w" )
14+
615config = ConfigParser ()
716config .read (".env" )
817FILE = config .get ("default" , "file" )
Original file line number Diff line number Diff line change 1+ from configparser import ConfigParser
2+ import argparse
3+ import sys , os
4+
5+ sys .stdout = open (os .devnull , "w" )
6+
7+ parser = argparse .ArgumentParser ()
8+ config = ConfigParser ()
9+
10+ parser .add_argument ("--github_access_token" , help = "Github access token" )
11+ parser .add_argument ("--aws_access_key_id" , help = "AWS access key id" )
12+ parser .add_argument ("--aws_secret_access_key" , help = "AWS secret access key" )
13+ parser .add_argument ("-b" , "--bucket" , help = "S3 bucket name" )
14+
15+ args = parser .parse_args ()
16+
17+ config .add_section ("github" )
18+ config .add_section ("aws" )
19+ config .add_section ("default" )
20+
21+
22+ config .set ("github" , "access_token" , args .github_access_token )
23+ config .set ("aws" , "aws_access_key_id" , args .aws_access_key_id )
24+ config .set ("aws" , "aws_secret_access_key" , args .aws_secret_access_key )
25+ config .set ("aws" , "bucket" , args .bucket )
26+ config .set ("default" , "file" , "voters.csv" )
27+
28+
29+ with open (file = "test.ini" , mode = "w+" , encoding = "utf-8" ) as f :
30+ config .write (f )
You can’t perform that action at this time.
0 commit comments