github.com/MetalBlockchain/metalgo@v1.11.9/.github/workflows/build-public-ami.yml (about) 1 name: build-public-ami 2 3 on: 4 workflow_dispatch: 5 inputs: 6 tag: 7 description: 'Tag to create AMI from' 8 required: true 9 push: 10 tags: 11 - "*" 12 13 env: 14 PACKER_VERSION: "1.10.2" 15 PYTHON3_BOTO3_VERSION: "1.20.34+dfsg-1" 16 17 jobs: 18 build-public-ami-and-upload: 19 runs-on: ubuntu-22.04 20 timeout-minutes: 45 21 22 steps: 23 - uses: actions/checkout@v4 24 - uses: ./.github/actions/setup-go-for-project 25 - run: go version 26 27 - name: Install aws cli 28 run: | 29 sudo apt update 30 sudo apt-get -y install python3-boto3="${PYTHON3_BOTO3_VERSION}" 31 32 - name: Get the tag 33 id: get_tag 34 run: | 35 if [[ ${{ github.event_name }} == 'push' ]]; 36 then 37 echo "TAG=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_ENV" 38 else 39 echo "TAG=${{ inputs.tag }}" >> "$GITHUB_ENV" 40 fi 41 shell: bash 42 43 - name: Set whether to skip ami creation in packer 44 run: | 45 if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then 46 echo "Setting SKIP_CREATE_AMI to False" 47 echo "SKIP_CREATE_AMI=False" >> "$GITHUB_ENV" 48 fi 49 50 - name: Configure AWS credentials 51 uses: aws-actions/configure-aws-credentials@v4 52 with: 53 aws-access-key-id: ${{ secrets.MARKETPLACE_ID }} 54 aws-secret-access-key: ${{ secrets.MARKETPLACE_KEY }} 55 aws-region: us-east-1 56 57 - name: Setup `packer` 58 uses: hashicorp/setup-packer@main 59 id: setup 60 with: 61 version: ${{ env.PACKER_VERSION }} 62 63 - name: Run `packer init` 64 id: init 65 run: "packer init ./.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl" 66 67 - name: Run `packer validate` 68 id: validate 69 run: "packer validate ./.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl" 70 71 - name: Create AMI and upload to marketplace 72 run: | 73 ./.github/workflows/update-ami.py 74 env: 75 TAG: ${{ env.TAG }} 76 PRODUCT_ID: ${{ secrets.MARKETPLACE_PRODUCT }} 77 ROLE_ARN: ${{ secrets.MARKETPLACE_ROLE }}