name: AWS AMI build using Packer config on: release: types: [published] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: version: description: "RELEASE_VERSION" jobs: packer-ee: runs-on: ubuntu-latest name: packer-ee steps: - name: Checkout code to lts-3.16 branch if: contains(github.event.release.tag_name, '-lts') uses: actions/checkout@v2 with: ref: refs/heads/lts-3.16 - name: Setting tag if: "${{ github.event.inputs.version != '' }}" run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV - name: Set evn if: "${{ github.event.release }}" run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1-node16 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-west-1 # Initialize Packer templates - name: Initialize Packer Template uses: hashicorp/packer-github-actions@master with: command: init target: . working_directory: deploy/ec2/ee # validate templates - name: Validate Template uses: hashicorp/packer-github-actions@master with: command: validate arguments: -syntax-only target: . working_directory: deploy/ec2/ee # Echo RENDER_GITHUB_PAT - name: Set PACKER_GITHUB_PAT run: echo "PACKER_GITHUB_PAT=${{ secrets.CUSTOM_GITHUB_TOKEN }}" >> $GITHUB_ENV # Dynamically update setup_machine.sh with PAT - name: Validate PAT run: | sed -i "s|git config --global url."https://x-access-token:CUSTOM_GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"|git config --global url."https://x-access-token:${ secrets.CUSTOM_GITHUB_TOKEN }@github.com/".insteadOf "https://github.com/"|g" ./deploy/ec2/ee/setup_machine.sh # build artifact - name: Build Artifact uses: hashicorp/packer-github-actions@master with: command: build #The the below argument is specific for building EE AMI image arguments: -color=false -on-error=abort -var ami_name=tooljet_${{ env.RELEASE_VERSION }}.ubuntu_jammy target: . working_directory: deploy/ec2/ee env: PACKER_LOG: 1 - name: Send Slack Notification run: | if [[ "${{ job.status }}" == "success" ]]; then message="ToolJet enterprise AWS AMI published:\\n\`tooljet_${{ env.RELEASE_VERSION }}.ubuntu-jammy\`" else message="ToolJet enterprise AWS AMI release failed! \\n\`tooljet_${{ env.RELEASE_VERSION }}.ubuntu-jammy\`" fi curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$message\"}" ${{ secrets.SLACK_WEBHOOK_URL }}