fix(build): make apt-get upgrade non-interactive in Docker builds #141
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 Taxonomy Service Image | |
| # GITHUB_TOKEN needs packages: write to push to ghcr.io (GitHub Container Registry) | |
| permissions: | |
| contents: read | |
| packages: write | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| check-config: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_build: ${{ steps.check.outputs.enabled }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Check if build is enabled | |
| id: check | |
| env: | |
| BUILD_ENABLED_VAR: ${{ vars.TAXONOMY_SERVICE_BUILD_ENABLED }} | |
| run: | | |
| if [ -n "$BUILD_ENABLED_VAR" ]; then | |
| ENABLED="$BUILD_ENABLED_VAR" | |
| echo "Taking value from TAXONOMY_SERVICE_BUILD_ENABLED: $ENABLED" | |
| else | |
| ENABLED=$(cat .github/build-config.json | jq -r '.services.taxonomy_service') | |
| echo "Taking value from build-config.json: $ENABLED" | |
| fi | |
| echo "enabled=$ENABLED" >> $GITHUB_OUTPUT | |
| echo "Taxonomy Service build enabled: $ENABLED" | |
| build-and-push: | |
| needs: check-config | |
| if: needs.check-config.outputs.should_build == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the code | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Step 2: Set up JDK 11 and Maven | |
| - name: Set up JDK 11 and Maven | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '11' | |
| cache: 'maven' | |
| # Step 3: Set up Login to Docker registry | |
| - name: Registry Login | |
| uses: ./.github/actions/registry-login | |
| with: | |
| registry_provider: ${{ vars.REGISTRY_PROVIDER }} | |
| gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | |
| registry_name: ${{ secrets.REGISTRY_NAME }} | |
| registry_url: ${{ secrets.REGISTRY_URL }} | |
| registry_username: ${{ secrets.REGISTRY_USERNAME }} | |
| registry_password: ${{ secrets.REGISTRY_PASSWORD }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| # Step 4: Build the project | |
| - name: Build Taxonomy API Service | |
| run: | | |
| mvn clean install -DskipTests=true | |
| # Step 5: Package the project | |
| - name: Package Taxonomy API Service | |
| run: | | |
| cd taxonomy-api | |
| mvn play2:dist -pl taxonomy-service | |
| # Step 6: Build Docker image | |
| - name: Build Docker Image | |
| run: | | |
| IMAGE_NAME="taxonomy-api" | |
| IMAGE_TAG=$(echo "${{ github.ref_name }}_$(echo $GITHUB_SHA | cut -c1-7)" | tr '[:upper:]' '[:lower:]') | |
| docker build -f build/taxonomy-service/Dockerfile -t $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} . | |
| echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV | |
| echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV | |
| # Step 7: Push Docker Image | |
| - name: Push Docker Image | |
| run: | | |
| docker push $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} | |
| echo "Pushed Docker image: $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG}" |