Merge pull request #4 from AlexVoin04/fix/ghcr-test #7
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 test-natk to GHCR | |
| on: | |
| push: | |
| branches: [ master ] | |
| workflow_dispatch: | |
| env: | |
| IMAGE_NAME: test-natk # имя образа | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 23 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '23' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Set lowercase owner | |
| run: | | |
| echo "OWNER_LC=${OWNER,,}" >> $GITHUB_ENV | |
| env: | |
| OWNER: ${{ github.repository_owner }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Make gradlew executable | |
| run: chmod +x ./gradlew | |
| - name: Build Docker image using Jib | |
| run: | | |
| ./gradlew :test-natk:jibDockerBuild --image=${{ env.IMAGE_NAME }}:latest | |
| - name: Tag and Push to GHCR | |
| run: | | |
| IMAGE_ID=ghcr.io/${{ env.OWNER_LC }}/${{ env.IMAGE_NAME }} | |
| VERSION=${{ github.sha }} | |
| # tag | |
| docker tag ${{ env.IMAGE_NAME }}:latest $IMAGE_ID:$VERSION | |
| docker tag ${{ env.IMAGE_NAME }}:latest $IMAGE_ID:latest | |
| # push | |
| docker push $IMAGE_ID:$VERSION | |
| docker push $IMAGE_ID:latest |