|
| 1 | +name: "Build & push devcontainer" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - .devcontainer/** |
| 9 | + - .github/workflows/build_images.yml |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - .devcontainer/** |
| 13 | + - .github/workflows/build_images.yml |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + packages: write # Required for GHCR |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-and-push: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + ruby_image: |
| 25 | + - ruby:2.7.8-slim-bullseye |
| 26 | + - ruby:3.0.7-slim-bullseye |
| 27 | + - ruby:3.1.7-slim-bookworm |
| 28 | + - ruby:3.2.9-slim-bookworm |
| 29 | + - ruby:3.3.9-slim-bookworm |
| 30 | + - ruby:3.4.5-slim-bookworm |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Check out current commit |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Generate short image name |
| 37 | + id: image_name |
| 38 | + run: | |
| 39 | + ruby_image="${{ matrix.ruby_image }}" |
| 40 | +
|
| 41 | + if [[ "$ruby_image" == ruby:* ]]; then |
| 42 | + version=$(echo "$ruby_image" | cut -d: -f2 | cut -d. -f1,2) |
| 43 | + short_name="sentry-ruby-devcontainer-${version}" |
| 44 | + elif [[ "$ruby_image" == jruby:latest ]]; then |
| 45 | + short_name="sentry-ruby-devcontainer-jruby-latest" |
| 46 | + elif [[ "$ruby_image" == jruby:* ]]; then |
| 47 | + version=$(echo "$ruby_image" | cut -d: -f2 | cut -d. -f1,2) |
| 48 | + short_name="sentry-ruby-devcontainer-jruby-${version}" |
| 49 | + else |
| 50 | + short_name="sentry-ruby-devcontainer-${ruby_image}" |
| 51 | + fi |
| 52 | +
|
| 53 | + echo "short_name=${short_name}" >> $GITHUB_OUTPUT |
| 54 | + echo "Generated short image name: ${short_name}" |
| 55 | +
|
| 56 | + - name: Build and push devcontainer image |
| 57 | + id: build |
| 58 | + uses: getsentry/action-build-and-push-images@main |
| 59 | + with: |
| 60 | + image_name: '${{ steps.image_name.outputs.short_name }}' |
| 61 | + dockerfile_path: '.devcontainer/Dockerfile' |
| 62 | + ghcr: true |
| 63 | + publish_on_pr: true |
| 64 | + build_args: | |
| 65 | + IMAGE=${{ matrix.ruby_image }} |
| 66 | +
|
| 67 | + - name: Use outputs |
| 68 | + run: | |
| 69 | + echo "GHCR URL: ${{ steps.build.outputs.ghcr_image_url }}" |
0 commit comments