put assume role after build #57
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: deploy-test-branch | |
# Controls when the action will run. | |
on: | |
push: | |
# Triggers the workflow on for any branch when a pull_request is opened or reopened | |
# pull_request: | |
# types: [opened, reopened] | |
# branches: [ * ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true | |
AWS_REGION: ${{ vars.AWS_REGION }} | |
DEPLOYMENT_ENV: ${{ vars[format('{0}_DEPLOYMENT_ENV', inputs.environment)] }} | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Install Jekyll dependencies | |
run: sudo dnf -y install ruby3.2 ruby3.2-devel openssl-devel amazon-rpm-config gcc-c++ | |
- name: Add ruby env vars | |
run: | | |
ruby -v | |
echo 'export GEM_HOME="$HOME/gems"' >> $GITHUB_ENV | |
echo 'export PATH="$HOME/ec2-user/bin:$HOME/gems/bin:$PATH"' >> $GITHUB_ENV | |
# echo "PREFIX=$RUNNER_TOOL_CACHE/Ruby/${ruby#ruby-}/$arch" >> $GITHUB_ENV | |
# comment | |
- name: Install Jekyll and bundler | |
run: | | |
sudo chmod -R 777 /usr/share | |
sudo gem install jekyll bundler | |
sudo bundle install | |
- name: "Build Site" | |
run: bundle exec jekyll build --baseurl /${{github.ref_name}} | |
env: | |
JEKYLL_ENV: test | |
- name: Assume role in AB2D Management account | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: arn:aws:iam::${{ secrets.MGMT_ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-mgmt-github-actions | |
# - name: "Debug Print - gets around secret filtering" | |
# run: echo AWS_BUCKET_NAME:${{secrets.AWS_S3_BUCKET_NAME}} | sed 's/./& /g' ; echo github.ref_name:${{github.ref_name}} | |
# | |
- name: "Deploy to AWS S3" | |
run: aws s3 sync ./_site/ s3://website-ab2d-east-impl/${{github.ref_name}}/ |