<commit_before>jobs:

  - name: provision
    type: runSh
    steps:
      - IN: waffle_cone_repo
        switch: off
      - IN: softsrv_pem
      - IN: softsrv_aws_creds
      - IN: pack
        switch: off
      - IN: tfState
        switch: off
      - TASK:
        - script: IN_STATE=/build/IN/tfState/state
        - script: if [ -f $IN_STATE/terraform.tfstate ]; then cp $IN_STATE/terraform.tfstate $WAFFLE_CONE_REPO_STATE/ ; fi
        - script: cd $WAFFLE_CONE_REPO_STATE
        - script: export LATEST_AMI=$PACK_VERSIONNAME
        - script: shippable_replace terraform.tfvars
        - script: terraform plan
        - script: terraform apply
      - OUT: tfState
    always:
      - script: echo 'save state if we created it'
      - script: OUT_STATE=/build/OUT/tfState/state
      - script: cp $WAFFLE_CONE_REPO_STATE/terraform.tfstate $OUT_STATE
    on_success:
      - script: PUBLIC_IP=$(terraform output machine_ip)
      - script: echo "versionName=$PUBLIC_IP" >> $JOB_STATE/$JOB_NAME.env

- name: destroy
  type: runSh
  steps:
    - IN: waffle_cone_repo
      switch: off
    - IN: softsrv_aws_creds
    - IN: tfState
      switch: off
    - TASK:
      - script: IN_STATE=/build/IN/tfState/state
      - script: if [ -f $IN_STATE/terraform.tfstate ]; then cp $IN_STATE/terraform.tfstate $WAFFLE_CONE_REPO_STATE ; fi
      - script: cd $WAFFLE_CONE_REPO_STATE
      - script: shippable_replace terraform.tfvars
      - script: terraform destroy
    - OUT: tfState
  always:
    - script: echo 'if statefile still exists, propagate it'
    - script: OUT_STATE="/build/OUT/tfState/state"
    - script: cp $WAFFLE_CONE_REPO_STATE/terraform.tfstate $OUT_STATE


  - name: pack
    type: runSh
    steps:
      - IN: waffle_cone_repo
        switch: off
      - IN: softsrv_aws_creds
      - TASK:
        - script: cd $WAFFLE_CONE_REPO_STATE/packer
        - script: packer build ami-definition.json 2>&1 | tee $JOB_STATE/output.txt
        - script: export AMI=$(tail -n1 $JOB_STATE/output.txt | awk '{print $2}')
        - script: echo "versionName=$AMI" >> $JOB_STATE/$JOB_NAME.env
    on_failure:<commit_msg>yml spacing<commit_after>jobs:

  - name: provision
    type: runSh
    steps:
      - IN: waffle_cone_repo
        switch: off
      - IN: softsrv_pem
      - IN: softsrv_aws_creds
      - IN: pack
        switch: off
      - IN: tfState
        switch: off
      - TASK:
        - script: IN_STATE=/build/IN/tfState/state
        - script: if [ -f $IN_STATE/terraform.tfstate ]; then cp $IN_STATE/terraform.tfstate $WAFFLE_CONE_REPO_STATE/ ; fi
        - script: cd $WAFFLE_CONE_REPO_STATE
        - script: export LATEST_AMI=$PACK_VERSIONNAME
        - script: shippable_replace terraform.tfvars
        - script: terraform plan
        - script: terraform apply
      - OUT: tfState
    always:
      - script: echo 'save state if we created it'
      - script: OUT_STATE=/build/OUT/tfState/state
      - script: cp $WAFFLE_CONE_REPO_STATE/terraform.tfstate $OUT_STATE
    on_success:
      - script: PUBLIC_IP=$(terraform output machine_ip)
      - script: echo "versionName=$PUBLIC_IP" >> $JOB_STATE/$JOB_NAME.env

  - name: destroy
    type: runSh
    steps:
      - IN: waffle_cone_repo
        switch: off
      - IN: softsrv_aws_creds
      - IN: tfState
        switch: off
      - TASK:
        - script: IN_STATE=/build/IN/tfState/state
        - script: if [ -f $IN_STATE/terraform.tfstate ]; then cp $IN_STATE/terraform.tfstate $WAFFLE_CONE_REPO_STATE ; fi
        - script: cd $WAFFLE_CONE_REPO_STATE
        - script: shippable_replace terraform.tfvars
        - script: terraform destroy
      - OUT: tfState
    always:
      - script: echo 'if statefile still exists, propagate it'
      - script: OUT_STATE="/build/OUT/tfState/state"
      - script: cp $WAFFLE_CONE_REPO_STATE/terraform.tfstate $OUT_STATE

  - name: pack
    type: runSh
    steps:
      - IN: waffle_cone_repo
        switch: off
      - IN: softsrv_aws_creds
      - TASK:
        - script: cd $WAFFLE_CONE_REPO_STATE/packer
        - script: packer build ami-definition.json 2>&1 | tee $JOB_STATE/output.txt
        - script: export AMI=$(tail -n1 $JOB_STATE/output.txt | awk '{print $2}')
        - script: echo "versionName=$AMI" >> $JOB_STATE/$JOB_NAME.env
    on_failure:
{'fraction_non_alphanumeric': 0.1014661391668606, 'fraction_numerical': 0.0018617640214102862, 'mean_word_length': 2.3240525908739365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '873376', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1525, 'n_words': 326}