|
| 1 | +name: "Publish PHP Auto-Instrumentation" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'autoinstrumentation/php/**' |
| 7 | + - '.github/workflows/publish-autoinstrumentation-php.yaml' |
| 8 | + branches: |
| 9 | + - main |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - 'autoinstrumentation/php/**' |
| 13 | + - '.github/workflows/publish-autoinstrumentation-php.yaml' |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + publish: |
| 22 | + runs-on: ubuntu-22.04 |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Read version |
| 28 | + run: echo "VERSION=$(cat autoinstrumentation/php/version.txt)" >> $GITHUB_ENV |
| 29 | + |
| 30 | + - name: Docker meta |
| 31 | + id: meta |
| 32 | + uses: docker/metadata-action@v5 |
| 33 | + with: |
| 34 | + images: | |
| 35 | + otel/autoinstrumentation-php |
| 36 | + ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-php |
| 37 | + tags: | |
| 38 | + type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} |
| 39 | +
|
| 40 | + - name: Set up Docker Buildx |
| 41 | + uses: docker/setup-buildx-action@v3 |
| 42 | + |
| 43 | + - name: Cache Docker layers |
| 44 | + uses: actions/cache@v4 |
| 45 | + with: |
| 46 | + path: /tmp/.buildx-cache |
| 47 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-buildx- |
| 50 | +
|
| 51 | + - name: Log into Docker.io |
| 52 | + uses: docker/login-action@v3 |
| 53 | + if: ${{ github.event_name == 'push' }} |
| 54 | + with: |
| 55 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 56 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 57 | + |
| 58 | + - name: Login to GitHub Package Registry |
| 59 | + uses: docker/login-action@v3 |
| 60 | + if: ${{ github.event_name == 'push' }} |
| 61 | + with: |
| 62 | + registry: ghcr.io |
| 63 | + username: ${{ github.repository_owner }} |
| 64 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + |
| 66 | + - name: Prepare files for docker image |
| 67 | + run: pushd ./autoinstrumentation/php ; ./prepare_files_for_docker_image.sh --ext-ver ${{ env.VERSION }} --dest-dir ${PWD}/files_for_docker_image ; popd |
| 68 | + |
| 69 | + - name: Build and push |
| 70 | + uses: docker/build-push-action@v6 |
| 71 | + with: |
| 72 | + context: autoinstrumentation/php |
| 73 | + push: ${{ github.event_name == 'push' }} |
| 74 | + build-args: SUB_DIR_WITH_FILES_FOR_DOCKER_IMAGE=files_for_docker_image |
| 75 | + tags: ${{ steps.meta.outputs.tags }} |
| 76 | + labels: ${{ steps.meta.outputs.labels }} |
| 77 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 78 | + cache-to: type=local,dest=/tmp/.buildx-cache |
0 commit comments