Skip to content

Build

Build #116

Workflow file for this run

name: "Build"
on:
workflow_dispatch:
schedule:
- cron: '45 4 * * 5' # At 04:45 on Friday
env:
AWS_REGION : "us-east-1"
AWS_ROLE: ${{ secrets.AWS_ROLE }}
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub
permissions:
contents: write
pages: write
id-token: write
jobs:
website:
name: Website
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
runs-on: ubuntu-latest
steps:
- name: 🐧 Install dependencies
run: |
sudo apt-get install \
libdbd-sqlite3-perl \
libjson-xs-perl \
libtemplate-perl \
libtext-csv-perl \
rclone \
sqlite3
- name: 🛎️ Checkout
uses: actions/checkout@v6
# Configure AWS Credentials for GitHub Actions
# https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions
- id: auth
name: 🔐 Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ env.AWS_ROLE }}
aws-region: ${{ env.AWS_REGION }}
- name: 🔨 Run build script
run: |
cd build || exit 9
bash build.sh || exit 9
- name: 📑 Create website
run: |
cd build || exit 9
perl web.pl || exit 9
- name: 🧪 Tests
run: |
cat "web/eu-central-1.html" | grep "Frankfurt" || exit 9
jq -e '.[] | .instanceType' "web/instances-locations.json" | grep "t3.medium" || exit 9
- name: 💾 Commit last build
run: |
cd build || exit 9
bash commit.sh || exit 9
- name: 🚀 Publish website
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_SERVER: ${{ secrets.SSH_SERVER }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_USER: ${{ secrets.SSH_USER }}
run: |
mkdir -p "$HOME/.ssh" || exit 9
echo "$SSH_KEY" > "$HOME/.ssh/deploy.key" || exit 9
chmod 600 "$HOME/.ssh/deploy.key" || exit 9
ssh-keyscan -p "$SSH_PORT" "$SSH_SERVER" >> "$HOME/.ssh/known_hosts" || exit 9
rclone copy "web/" ":sftp:/var/www/aws-pricing.com" \
--sftp-host "$SSH_SERVER" \
--sftp-port "$SSH_PORT" \
--sftp-user "$SSH_USER" \
--sftp-key-file "$HOME/.ssh/deploy.key" \
--sftp-known-hosts-file "$HOME/.ssh/known_hosts" \
--transfers 32 --checkers 64 || exit 9