Allow positively overriding hostname #436
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| # This workflow builds and pushes Docker images to public repositories: | |
| # - Pull requests: Tagged as pr-NUMBER (e.g., pr-59) | |
| # - Main branch: Tagged as canary | |
| # - Version tags: Tagged as the version and latest | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-collector: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Modify COLLECTOR_VERSION for branch builds | |
| if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }} | |
| run: | | |
| # Get short SHA (first 7 characters) | |
| SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
| # Determine the suffix based on build type | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| # PR build: add -prX-SHA suffix | |
| SUFFIX="-pr${{ github.event.pull_request.number }}-${SHORT_SHA}" | |
| elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| # Main branch build: add -canary-SHA suffix | |
| SUFFIX="-canary-${SHORT_SHA}" | |
| fi | |
| # Modify the Dockerfile to append suffix to COLLECTOR_VERSION | |
| sed -i "s/^ENV COLLECTOR_VERSION=\(.*\)/ENV COLLECTOR_VERSION=\1${SUFFIX}/" collector/Dockerfile | |
| # Show what was changed for debugging | |
| echo "Modified COLLECTOR_VERSION:" | |
| grep "^ENV COLLECTOR_VERSION=" collector/Dockerfile | |
| - name: Ensure tag version matches collector version | |
| id: ensure-tag-version | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| sed -i "s/^ENV COLLECTOR_VERSION=.*/ENV COLLECTOR_VERSION=${GITHUB_REF#refs\/tags\/v}/" collector/Dockerfile | |
| git diff --exit-code | |
| fi | |
| - name: Determine repository and tags | |
| id: repo | |
| run: | | |
| # Always use public repo | |
| echo "repository=betterstack/collector" >> $GITHUB_OUTPUT | |
| echo "push=true" >> $GITHUB_OUTPUT | |
| - name: Set up Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ steps.repo.outputs.repository }} | |
| tags: | | |
| # For version tags, tag as version and latest | |
| type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| # For main branch, tag as canary | |
| type=raw,value=canary,enable=${{ github.ref == 'refs/heads/main' }} | |
| # For pull requests, tag as pr-NUMBER | |
| type=raw,value=pr-${{ github.event.pull_request.number }},enable=${{ github.event_name == 'pull_request' }} | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Depot | |
| uses: depot/setup-action@v1 | |
| - name: Build and push Docker image | |
| uses: depot/build-push-action@v1 | |
| with: | |
| project: ${{ secrets.DEPOT_PROJECT_ID }} | |
| token: ${{ secrets.DEPOT_API_TOKEN }} | |
| context: . | |
| file: collector/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ steps.repo.outputs.push }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| COLLECTOR_VERSION=${{ github.ref_name }} | |
| build-beyla: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Determine repository and tags | |
| id: repo | |
| run: | | |
| # Always use public repo | |
| echo "repository=betterstack/collector-beyla" >> $GITHUB_OUTPUT | |
| echo "push=true" >> $GITHUB_OUTPUT | |
| - name: Set up Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ steps.repo.outputs.repository }} | |
| tags: | | |
| # For version tags, tag as version and latest | |
| type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| # For main branch, tag as canary | |
| type=raw,value=canary,enable=${{ github.ref == 'refs/heads/main' }} | |
| # For pull requests, tag as pr-NUMBER | |
| type=raw,value=pr-${{ github.event.pull_request.number }},enable=${{ github.event_name == 'pull_request' }} | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Depot | |
| uses: depot/setup-action@v1 | |
| - name: Build and push Docker image | |
| uses: depot/build-push-action@v1 | |
| with: | |
| project: ${{ secrets.DEPOT_PROJECT_ID }} | |
| token: ${{ secrets.DEPOT_API_TOKEN }} | |
| context: . | |
| file: beyla/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ steps.repo.outputs.push }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |