This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
generated from Sage-Bionetworks-IT/packer-ami-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.travis.yml
44 lines (44 loc) · 1.7 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
language: python
python: 3.8
cache: pip
env:
global:
- REPO_NAME="${PWD##*/}"
- IMAGE_NAME="${REPO_NAME}-${TRAVIS_BRANCH}"
- AWS_PROFILE="ci-role"
- AWS_REGION="us-east-1"
install:
# install packer
- curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
- sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
- sudo apt-get update && sudo apt-get install packer
# install awscli v2
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
- unzip awscliv2.zip && sudo ./aws/install
# install other tools
- pip install pre-commit travis-wait-improved ansible
before_script:
- mkdir -p ~/.aws
- echo -e "[profile ${AWS_PROFILE}]\nregion=${AWS_REGION}\nsource_profile=ci-user\nrole_arn=${AwsCfServiceRoleArn}" > ~/.aws/config
- echo -e "[ci-user]\nregion=${AWS_REGION}\naws_access_key_id=${AwsTravisAccessKey}\naws_secret_access_key=${AwsTravisSecretAccessKey}" > ~/.aws/credentials
stages:
- name: validate
- name: deploy-branch
if: type = push AND branch = master
- name: deploy-tag
if: tag =~ ^v[0-9]+\.[0-9]+\.[0-9]
jobs:
include:
- stage: validate
script:
- pre-commit run --all-files
- pushd src
- packer validate -var ImageName=${IMAGE_NAME} template.json
- stage: deploy-branch
script:
- pushd src
- travis-wait-improved --timeout 75m packer build -force -var AwsProfile=${AWS_PROFILE} -var ImageName=${IMAGE_NAME} template.json
- stage: deploy-tag
script:
- pushd src
- travis-wait-improved --timeout 75m packer build -force -var AwsProfile=${AWS_PROFILE} -var ImageName=${IMAGE_NAME} template.json