Merge pull request #36 from Azure-Samples/gk/26-aggregate-miyagi-skil… #6
This file contains 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: User Service Build and Push to GHCR | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'services/user-service/**' | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
REPOSITORY: ${{ github.repository }} | |
jobs: | |
set-env: | |
name: Set Environment Variables | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.main.outputs.version }} | |
created: ${{ steps.main.outputs.created }} | |
project: ${{ steps.main.outputs.project }} | |
image: ${{ steps.main.outputs.image }} | |
repository: ${{ steps.main.outputs.repository }} | |
steps: | |
- id: main | |
run: | | |
echo ::set-output name=version::$(echo ${GITHUB_SHA} | cut -c1-7) | |
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
echo ::set-output name=project::user-service | |
echo ::set-output name=image::${{ env.REGISTRY }}/${{ env.REPOSITORY }}/user-service:${{ github.sha }} | |
echo ::set-output name=repository::ghcr.io/${{ env.REPOSITORY }}/user-service | |
package-service: | |
name: Package Service | |
runs-on: ubuntu-latest | |
needs: set-env | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- name: Set up Maven | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- name: Build with Maven | |
run: mvn -B package --file ./services/user-service/pom.xml -DskipTests | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.CR_PAT }} | |
- name: downcase env.REPOSITORY | |
run: | | |
echo "REPOSITORY=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: services/user-service | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/user-service:${{ github.sha }} |