|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + environment: |
| 7 | + description: "Target environment tag value" |
| 8 | + required: true |
| 9 | + default: staging |
| 10 | + type: choice |
| 11 | + options: [staging, production] |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - develop |
| 15 | + |
| 16 | +env: |
| 17 | + MINIMUM_PACKAGE_AGE_HOURS: 0 |
| 18 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 19 | + SAFE_CHAIN_VERSION: "1.4.7" |
| 20 | + SAFE_CHAIN_SHA256: "54c750232d149106ecf4f5f28fee82ba49d2428f1e411e0ed961c0263ae19eaf" |
| 21 | + |
| 22 | +permissions: |
| 23 | + id-token: write |
| 24 | + contents: read |
| 25 | + |
| 26 | +jobs: |
| 27 | + test: |
| 28 | + name: Integration test |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 34 | + |
| 35 | + - name: Setup Bun |
| 36 | + uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 |
| 37 | + |
| 38 | + - name: Install safe-chain |
| 39 | + run: | |
| 40 | + curl -fsSL "https://github.com/AikidoSec/safe-chain/releases/download/${SAFE_CHAIN_VERSION}/install-safe-chain.sh" \ |
| 41 | + -o install-safe-chain.sh |
| 42 | + echo "${SAFE_CHAIN_SHA256} install-safe-chain.sh" | sha256sum --check |
| 43 | + sh install-safe-chain.sh --ci |
| 44 | +
|
| 45 | + - name: Install dependencies |
| 46 | + run: bun install |
| 47 | + env: |
| 48 | + SAFE_CHAIN_MINIMUM_PACKAGE_AGE_HOURS: ${{ env.MINIMUM_PACKAGE_AGE_HOURS }} |
| 49 | + |
| 50 | + - name: Configure AWS credentials (OIDC) |
| 51 | + uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0 |
| 52 | + with: |
| 53 | + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} |
| 54 | + aws-region: ${{ secrets.AWS_REGION }} |
| 55 | + |
| 56 | + - name: Deploy to ${{ inputs.environment || 'production' }} |
| 57 | + id: deploy |
| 58 | + uses: ./ |
| 59 | + with: |
| 60 | + aws-region: us-east-1 |
| 61 | + # Targets all instances tagged env=<environment> AND role=web |
| 62 | + targets: | |
| 63 | + Key=tag:env,Values=${{ inputs.environment || 'production' }} |
| 64 | + Key=tag:role,Values=web |
| 65 | + working-directory: /home/ec2-user |
| 66 | + wait-for-output: true |
| 67 | + wait-timeout: 180 |
| 68 | + comment: Deploy ${{ github.sha }} to ${{ inputs.environment || 'production' }} |
| 69 | + command: | |
| 70 | + echo `date +%Y-%m-%dT%H:%M:%S%z` "Hello from tester-tag.yml" >> logs.txt |
| 71 | + cat logs.txt |
| 72 | +
|
| 73 | + - name: Print output |
| 74 | + run: echo "${{ steps.deploy.outputs.output }}" |
0 commit comments