-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (69 loc) · 2.72 KB
/
refresh-data.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: refresh-data
on:
workflow_dispatch:
inputs:
tags:
description:
"run from cmdline"
schedule:
- cron: '30 1 * * THU'
push:
branches:
- master
- main
jobs:
refresh-data:
runs-on: ubuntu-latest
env:
R_CONFIG_ACTIVE: github
GITHUB_PAT: ${{ secrets.DJPRDASHDATA_PAT }}
PG_MASTER_USER: ${{ secrets.PG_MASTER_USER }}
PG_MASTER_PW: ${{ secrets.PG_MASTER_PW }}
PG_READ_OPEN_USER: ${{ secrets.PG_READ_OPEN_USER }}
PG_READ_OPEN_PW: ${{ secrets.PG_READ_OPEN_PW }}
IVI_REGIONS: ${{ vars.IVI_REGIONS }}
IVI_ANZSCO4: ${{ vars.IVI_ANZSCO4 }}
steps:
- uses: actions/checkout@v3
- name: Installing extra system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --fix-missing libcurl4-openssl-dev
- uses: r-lib/actions/setup-r@v2
with:
r-version: 'renv' # The R version to download (if necessary) and use.
- uses: r-lib/actions/setup-renv@v2
- uses: r-lib/actions/setup-pandoc@v2
- name: Get Github action IP
id: ip
uses: haythem/[email protected]
- name: Set AWS environment variables
run: |
echo "AWS_DEFAULT_REGION=ap-southeast-2" >> $GITHUB_ENV
echo "AWS_SG_NAME=sg-0b7365fabbbc1c55b" >> $GITHUB_ENV
- name: Add Github Actions IP to Security group
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ env.AWS_SG_NAME }} --protocol tcp --port 5432 --cidr ${{ steps.ip.outputs.ipv4 }}/32
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}
- name: Get data
run: Rscript -e 'source(here::here("data-raw", "refresh_data.R"), echo = TRUE)'
- name: Render README
run: Rscript -e 'rmarkdown::render(here::here("README.Rmd"))'
- name: Commit
run: |
git config --global user.name 'Henry McMillan'
git config --global user.email '[email protected]'
git add .
git commit -m 'refreshing data' || echo "No changes to commit"
git push --force origin main || echo "No changes to commit"
- name: Remove Github Actions IP from security group
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ env.AWS_SG_NAME }} --protocol tcp --port 5432 --cidr ${{ steps.ip.outputs.ipv4 }}/32
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}
if: always()