Set the pipeline to run automatically on PRs and new branch creation. #137
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate aws-rds-postgresql blueprint | |
on: | |
pull_request: | |
types: [opened, synchronize] # Run on PR creation and updates | |
push: | |
branches: [ "master", "main" ] | |
paths: | |
- "./aws-rds-postgresql/generic/terraform/module.tf" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
Generate-files: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Install JQ | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq | |
- name: Determine latest Core module tag | |
run: | | |
LATEST_TAG=$(curl -s https://api.github.com/repos/dfds/terraform-aws-rds/tags | jq -r '.[0].name') | |
echo "Latest tag: $LATEST_TAG" | |
echo "TAG_NAME=$LATEST_TAG" >> $GITHUB_ENV | |
- name: Download latest Core module | |
run: | | |
curl -L https://github.com/dfds/terraform-aws-rds/archive/refs/tags/${TAG_NAME}.tar.gz > terraform-aws-rds.tar.gz | |
tar -xf terraform-aws-rds.tar.gz ; mv terraform-aws-rds-${TAG_NAME} $GITHUB_WORKSPACE/aws-rds-postgresql/aws-modules-rds ; rm -rf terraform-aws-rds.tar.gz | |
shell: bash | |
- name: Build docker image | |
working-directory: aws-rds-postgresql/aws-modules-rds/tools | |
run: | | |
docker build -t scaffold:latest . | |
shell: bash | |
- name: Run script | |
run: | | |
input=$(pwd)/aws-rds-postgresql/aws-modules-rds/ | |
output=$(pwd)/aws-rds-postgresql/generic/ | |
if [ -d $output ]; then | |
rm -rf $output | |
fi | |
mkdir -p $output | |
docker run -v $input:/input -v $output:/output scaffold:latest | |
shell: bash | |
- name: setup git config | |
run: | | |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: commit | |
run: | | |
git status | |
# Stage the file, commit and push | |
git add $(pwd)/aws-rds-postgresql/generic/ | |
git commit -m "update blueprints for RDS module" | |
git push |