|
| 1 | +name: Deploy Process |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-20.04 |
| 12 | + steps: |
| 13 | + |
| 14 | + with: |
| 15 | + secrets: ${{ toJSON(secrets) }} |
| 16 | + - name: Specify PHP version |
| 17 | + uses: shivammathur/setup-php@v2 |
| 18 | + with: |
| 19 | + php-version: '5.6' |
| 20 | + - name: Make branch name available as Bash variable |
| 21 | + run: echo "GITHUB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV |
| 22 | + - run: >- |
| 23 | + sudo apt-get update && |
| 24 | + sudo apt-get install -y awscli php5.6-cli php5.6-curl php5.6-memcached php5.6-mysql yarn zip |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + - run: sudo apt-get update -qq |
| 27 | + - run: git clone -b deploy https://github.com/openva/richmondsunlight.com.git |
| 28 | + - run: cd richmondsunlight.com && composer install && cd .. |
| 29 | + - run: mkdir includes/ |
| 30 | + - run: cp richmondsunlight.com/htdocs/includes/*.php includes/ |
| 31 | + - run: rm -Rf richmondsunlight.com |
| 32 | + - run: composer install |
| 33 | + - run: find cron/*.php -print0 |xargs -0 -n1 -P8 php5.6 -l |
| 34 | + - run: >- |
| 35 | + ./deploy/config_variables.sh |
| 36 | + && ./deploy/aws_credentials.sh |
| 37 | + && ./deploy/sftp_credentials.sh |
| 38 | + && zip -qr latest.zip rs-machine . --exclude *.git* *.scannerwork* |
| 39 | + && mkdir -p upload |
| 40 | + && mv latest.zip upload/latest.zip |
| 41 | + - run: cd deploy/tests/ && ./legislator.sh && cd ../.. |
| 42 | + - name: Save secret-populated code for a subsequent deploy step |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: codebase |
| 46 | + path: . |
| 47 | + outputs: |
| 48 | + github_branch: ${{ steps.get_branch.outputs.github_branch }} |
| 49 | + |
| 50 | + deploy: |
| 51 | + runs-on: ubuntu-20.04 |
| 52 | + needs: build # Don't deploy unless the build succeeds |
| 53 | + steps: |
| 54 | + - name: Get the secret-populated code |
| 55 | + uses: actions/download-artifact@v4 |
| 56 | + with: |
| 57 | + name: codebase |
| 58 | + - name: Configure AWS credentials |
| 59 | + uses: aws-actions/configure-aws-credentials@v3 |
| 60 | + with: |
| 61 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} |
| 62 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} |
| 63 | + aws-region: us-east-1 |
| 64 | + - name: Deploy via CodeDeploy |
| 65 | + if: ${{ needs.build.outputs.github_branch == 'master' }} |
| 66 | + run: | |
| 67 | + aws deploy push --application-name RS-API \ |
| 68 | + --s3-location s3://deploy.richmondsunlight.com/rs-api-master.zip \ |
| 69 | + --ignore-hidden-files |
| 70 | + aws deploy create-deployment \ |
| 71 | + --application-name RS-API \ |
| 72 | + --deployment-group-name RS-API-Fleet \ |
| 73 | + --deployment-config-name CodeDeployDefault.OneAtATime \ |
| 74 | + --s3-location bucket=deploy.richmondsunlight.com,key=rs-api-master.zip,bundleType=zip |
0 commit comments