Merge pull request #28 from ikochuev/lesson30 #9
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: CI Pipeline Lesson28 | |
| on: | |
| push: | |
| branches: [ main, lesson28 ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| app: [hello-world, hello-jenkins, hello-devops] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Test ${{ matrix.app }} | |
| run: mvn -B test --file lesson28/${{ matrix.app }}/pom.xml | |
| - name: Build ${{ matrix.app }} | |
| run: mvn -B package -DskipTests --file lesson28/${{ matrix.app }}/pom.xml | |
| - name: Upload ${{ matrix.app }} JAR | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.app }}-jar | |
| path: lesson28/${{ matrix.app }}/target/*.jar | |
| docker-build-push: | |
| runs-on: ubuntu-latest | |
| needs: build-test | |
| strategy: | |
| matrix: | |
| app: [hello-world, hello-jenkins, hello-devops] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download ${{ matrix.app }} JAR | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ matrix.app }}-jar | |
| path: lesson28/${{ matrix.app }}/target/ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push ${{ matrix.app }} | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: lesson28/${{ matrix.app }}/ | |
| push: true | |
| tags: | | |
| ghcr.io/ikochuev/codeby-devops-${{ matrix.app }}:${{ github.sha }} | |
| ghcr.io/ikochuev/codeby-devops-${{ matrix.app }}:latest |