Skip to content

feat: download aggregated data from the s3 bucket during the report g… #100

feat: download aggregated data from the s3 bucket during the report g…

feat: download aggregated data from the s3 bucket during the report g… #100

Workflow file for this run

name: Run Plot Action and Upload Results
on:
push:
branches:
- main
workflow_dispatch:
jobs:
plot-and-publish:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'release-please--branches--main')"
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v3
- name: Setup JDK 18
uses: actions/setup-java@v3
with:
java-version: '18'
distribution: 'temurin'
cache: maven
- name: Setup dependencies
run: |
pip install yq
- name: ⬇️ Download test data
uses: keithweaver/[email protected]
with:
command: cp
source: ${{ secrets.AWS_S3_BUCKET }}
destination: /data/rewards-calculation-test-data
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_REGION }}
flags: --recursive
- name: 🍀 Generate .env file
run: |
echo "SPRING_PROFILES_ACTIVE=ci" >> src/test/resources/.env
echo "JSON_DATA_SOURCE_FOLDER=/data/rewards-calculation-test-data" >> src/test/resources/.env
- name: Build
run: |
mvn --batch-mode --update-snapshots clean package -DskipTests && mv target/rewards-*.jar target/rewards-calculation.jar
- name: 📊 Generate plots
run: java -jar target/rewards-calculation.jar --action=plot
- name: JSON result to js file
run: |
echo -e "const treasuryCalculationResult = $(cat ./report/treasury_calculation_result.json)" > ./report/treasury_calculation_result.js
- name: 👀 Lookup metadata for report
run: |
echo "VERSION=$(xq -r .project.version pom.xml)" >> $GITHUB_ENV
echo "LATEST_COMMIT_HASH=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_ENV
echo "LATEST_COMMIT_HASH_SHORT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
echo "UTC_DATE=$(date -uR|sed 's/.....$//')" >> $GITHUB_ENV
- name: 📂 Create report directory
run: |
mkdir -p report-v${{ env.VERSION }}
- name: 📄 Copy report files
run: |
cp -r report/* report-v${{ env.VERSION }}
- name: 📝 Add metadata to the report
run: |
sed -i 's|<footer></footer>|<footer><p>Created on ${{ env.UTC_DATE }} UTC as a result of modifications triggered by <a href="https://github.com/cardano-foundation/cf-java-rewards-calculation/commit/${{ env.LATEST_COMMIT_HASH }}">${{ env.LATEST_COMMIT_HASH_SHORT }}</a></p></footer>|' report-v${{ env.VERSION }}/treasury_calculation.html
- name: 📅 Publish report to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
BRANCH: gh-pages
folder: report-v${{ env.VERSION }}
target-folder: report-latest/
- name: 📅 Publish report to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
BRANCH: gh-pages
folder: report-v${{ env.VERSION }}
target-folder: report-v${{ env.VERSION }}/