|
| 1 | +name: CX build and push |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ 'main', 'matt/bpf-loop-fallback' ] |
| 6 | + pull_request: |
| 7 | + branches: [ 'matt/bpf-loop-fallback' ] |
| 8 | + |
| 9 | +env: |
| 10 | + AWS_REGION: eu-west-1 |
| 11 | + AWS_ACCOUNT_ID: 897729105761 # tacotaco-research |
| 12 | + AWS_ROLE_TO_ASSUME: arn:aws:iam::897729105761:role/AnemiaAgentRole |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-and-push: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + if: github.repository == 'coralogix/opentelemetry-ebpf-instrumentation' |
| 18 | + permissions: |
| 19 | + id-token: write |
| 20 | + packages: write |
| 21 | + contents: read |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Configure AWS credentials |
| 28 | + uses: aws-actions/configure-aws-credentials@v4 |
| 29 | + with: |
| 30 | + role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} |
| 31 | + aws-region: ${{ env.AWS_REGION }} |
| 32 | + |
| 33 | + - name: Login to Amazon ECR |
| 34 | + id: login-ecr |
| 35 | + run: | |
| 36 | + aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com |
| 37 | +
|
| 38 | + - name: Create ECR Repositories |
| 39 | + run: | |
| 40 | + aws ecr create-repository --repository-name "obi-internal" --region ${{ env.AWS_REGION }} || echo "Repository obi-internal already exists." |
| 41 | +
|
| 42 | + - name: Set up buildx |
| 43 | + uses: docker/setup-buildx-action@v3 |
| 44 | + with: |
| 45 | + driver: docker-container |
| 46 | + |
| 47 | + - name: Cache images |
| 48 | + uses: actions/cache@v3 |
| 49 | + with: |
| 50 | + path: /tmp/.buildx-cache |
| 51 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 52 | + restore-keys: | |
| 53 | + ${{ runner.os }}-buildx- |
| 54 | +
|
| 55 | + - name: Set Git Commit Hash |
| 56 | + run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 57 | + |
| 58 | + - name: Build and push |
| 59 | + uses: docker/build-push-action@v6 |
| 60 | + with: |
| 61 | + platforms: linux/amd64,linux/arm64 |
| 62 | + context: . |
| 63 | + file: ./Dockerfile |
| 64 | + push: true |
| 65 | + tags: | |
| 66 | + ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/obi-internal:${{ env.COMMIT_HASH }} |
| 67 | + ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/obi-internal:latest |
| 68 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 69 | + cache-to: type=local,dest=/tmp/.buildx-cache,new=true |
0 commit comments