Build Images #108
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: Build Images | |
on: | |
workflow_dispatch: | |
jobs: | |
validate: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
machine: [backend, cron, taskrunner, sftp] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Validate json | |
run: | | |
cd images | |
packer validate -var-file=${{ matrix.machine }}.json image.json | |
build: | |
runs-on: ubuntu-20.04 | |
needs: ["validate"] | |
strategy: | |
matrix: | |
machine: [backend, taskrunner, cron, sftp] | |
environment: | |
- perm_env: dev | |
server_domain: "dev.permanent.org" | |
app_id: "TEST.org.permanent.permanent.dev" | |
aws_deploy_key: DEV_AWS_ACCESS_KEY_ID | |
aws_deploy_secret: DEV_AWS_SECRET_ACCESS_KEY | |
new_relic_application_name: Backend-dev | |
new_relic_license_key: DEV_NEW_RELIC_LICENSE_KEY | |
notification_database_url: DEV_NOTIFICATION_DATABASE_URL | |
notification_firebase_credentials: DEV_NOTIFICATION_FIREBASE_CREDENTIALS | |
fusion_auth_host_secret_key: DEV_FUSION_AUTH_HOST | |
fusion_auth_key_sftp_secret_key: DEV_FUSION_AUTH_KEY_SFTP | |
- perm_env: staging | |
server_domain: "staging.permanent.org" | |
app_id: "C8YKZNBVWT.org.permanent.permanent.staging" | |
aws_deploy_key: STAGING_AWS_ACCESS_KEY_ID | |
aws_deploy_secret: STAGING_AWS_SECRET_ACCESS_KEY | |
new_relic_license_key: STAGING_NEW_RELIC_LICENSE_KEY | |
new_relic_application_name: Backend-staging | |
notification_database_url: STAGING_NOTIFICATION_DATABASE_URL | |
notification_firebase_credentials: STAGING_NOTIFICATION_FIREBASE_CREDENTIALS | |
fusion_auth_host_secret_key: STAGING_FUSION_AUTH_HOST | |
fusion_auth_key_sftp_secret_key: STAGING_FUSION_AUTH_KEY_SFTP | |
- perm_env: prod | |
server_domain: "www.permanent.org" | |
app_id: "C8YKZNBVWT.org.permanent.PermanentArchive" | |
aws_deploy_key: PROD_AWS_ACCESS_KEY_ID | |
aws_deploy_secret: PROD_AWS_SECRET_ACCESS_KEY | |
new_relic_license_key: PROD_NEW_RELIC_LICENSE_KEY | |
new_relic_application_name: Backend-prod | |
notification_database_url: PROD_NOTIFICATION_DATABASE_URL | |
notification_firebase_credentials: PROD_NOTIFICATION_FIREBASE_CREDENTIALS | |
fusion_auth_host_secret_key: PROD_FUSION_AUTH_HOST | |
fusion_auth_key_sftp_secret_key: PROD_FUSION_AUTH_KEY_SFTP | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Build image | |
run: | | |
ansible-galaxy install willshersystems.sshd | |
ansible-galaxy collection install 'community.general:<3.3.0' | |
cd images | |
packer build -var-file=${{ matrix.machine }}.json image.json | |
env: | |
APP_ID: ${{ matrix.environment.app_id }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
DEPLOY_AWS_ACCESS_KEY_ID: ${{ secrets[matrix.environment.aws_deploy_key] }} | |
DEPLOY_AWS_SECRET_ACCESS_KEY: ${{ secrets[matrix.environment.aws_deploy_secret] }} | |
NEW_RELIC_LICENSE_KEY: ${{ secrets[matrix.environment.new_relic_license_key] }} | |
NEW_RELIC_APPLICATION_NAME: ${{ matrix.environment.new_relic_application_name }} | |
NOTIFICATION_DATABASE_URL: ${{ secrets[matrix.environment.notification_database_url] }} | |
NOTIFICATION_FIREBASE_CREDENTIALS: ${{ secrets[matrix.environment.notification_firebase_credentials] }} | |
SENTRY_DSN: ${{ secrets.SENTRY_TOKEN }} | |
PERM_ENV: ${{ matrix.environment.perm_env }} | |
SERVER_DOMAIN: ${{ matrix.environment.server_domain }} | |
FUSION_AUTH_HOST: ${{ secrets[matrix.environment.fusion_auth_host_secret_key] }} | |
FUSION_AUTH_KEY_SFTP: ${{ secrets[matrix.environment.fusion_auth_key_sftp_secret_key] }} | |
notify: | |
runs-on: ubuntu-20.04 | |
needs: ["build"] | |
steps: | |
- name: Send Slack notification | |
run: curl -X POST -H 'Content-type:application/json' --data '{"text":"Done building new images"}' https://hooks.slack.com/services/TBBFM3TEY/BJKUMT4CC/${{ secrets.SLACK_KEY }} |