-
Notifications
You must be signed in to change notification settings - Fork 7
Azure migration #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure migration #242
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,53 @@ | ||
| name: Build and Deploy to AWS | ||
| name: Build and Deploy to Azure | ||
| run-name: "Production Deployment #${{ github.run_number }}" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| env: | ||
| JAR_FILENAME: Lobby-Platform | ||
| ARTIFACT_NAME: backend-app | ||
| SYSTEMD_SERVICE_NAME: lobby-platform | ||
|
|
||
| permissions: | ||
| id-token: write # This is required for requesting the JWT | ||
| contents: read # This is required for actions/checkout | ||
| id-token: write # This is required for Azure login | ||
| contents: read # This is required for actions/checkout | ||
| packages: write # This is required for publishing the package | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build on GitHub | ||
| runs-on: ubuntu-latest | ||
| ci: | ||
| name: CI | ||
| uses: ./.github/workflows/template-ci-build.yml | ||
|
|
||
| deploy: | ||
| name: Deploy to Azure | ||
| runs-on: ubuntu-latest | ||
| needs: ci | ||
| environment: production | ||
| env: | ||
| AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | ||
| AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} | ||
| AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | ||
| AZURE_APPSVC_NAME: ${{ vars.AZURE_APPSVC_NAME }} | ||
| AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }} | ||
| steps: | ||
| # Checkout the repo | ||
| - name: git checkout | ||
| uses: actions/checkout@v3 | ||
|
|
||
| # Setup JDK 17 | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v3 | ||
| # Az Login | ||
| - name: Az Login | ||
| uses: azure/login@v1 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'corretto' | ||
|
|
||
| # Maven Verify | ||
| - name: Maven Verify | ||
| run: ./mvnw -B verify -DJAR_FILENAME=${{ env.JAR_FILENAME }} | ||
| client-id: ${{ env.AZURE_CLIENT_ID }} | ||
| tenant-id: ${{ env.AZURE_TENANT_ID }} | ||
| subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }} | ||
|
|
||
| # Dump GitHub Context | ||
| - name: Dump GitHub Context | ||
| env: | ||
| GITHUB_CONTEXT: ${{ toJSON(github) }} | ||
| # Set App Service Image to Latest | ||
| - name: Set App Service Image to Latest | ||
| run: | | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| echo "$GITHUB_CONTEXT" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| az webapp config container set \ | ||
| --name ${{ env.AZURE_APPSVC_NAME }} \ | ||
| --resource-group ${{ env.AZURE_RESOURCE_GROUP }} \ | ||
| --container-image-name ${{ needs.ci.outputs.image }} | ||
|
|
||
| az webapp restart \ | ||
| --name ${{ env.AZURE_APPSVC_NAME }} \ | ||
| --resource-group ${{ env.AZURE_RESOURCE_GROUP }} | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: PR Build | ||
| run-name: "PR - Build #${{ github.run_number }}" | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| ci: | ||
| name: CI | ||
| uses: ./.github/workflows/template-ci-build.yml | ||
| with: | ||
| push-image: false |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,78 @@ | ||||||||||||||||||||||
| name: Reusable Build Workflow | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| on: | ||||||||||||||||||||||
| workflow_call: | ||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||
| push-image: | ||||||||||||||||||||||
| description: "Whether to push the Docker image to the registry" | ||||||||||||||||||||||
| required: false | ||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||
| default: true | ||||||||||||||||||||||
| outputs: | ||||||||||||||||||||||
| image: | ||||||||||||||||||||||
| description: "The full Docker image with registry/repository:tag" | ||||||||||||||||||||||
| value: ${{ jobs.build.outputs.image }} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| env: | ||||||||||||||||||||||
| JAR_FILENAME: Lobby-Platform | ||||||||||||||||||||||
| JAR_OUTPUT_PATH: spring/target | ||||||||||||||||||||||
| DOCKERFILE_PATH: docker/Dockerfile | ||||||||||||||||||||||
| CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }} | ||||||||||||||||||||||
| CONTAINER_REPOSITORY: ${{ vars.CONTAINER_REPOSITORY }} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||
| contents: read # This is required for actions/checkout | ||||||||||||||||||||||
| packages: write # This is required for publishing the package | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||
| build: | ||||||||||||||||||||||
| name: Build on GitHub | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| outputs: | ||||||||||||||||||||||
| image: ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| # Checkout the repo | ||||||||||||||||||||||
| - name: git checkout | ||||||||||||||||||||||
| uses: actions/checkout@v3 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Setup JDK 17 | ||||||||||||||||||||||
| - name: Set up JDK 17 | ||||||||||||||||||||||
| uses: actions/setup-java@v3 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| java-version: "17" | ||||||||||||||||||||||
| distribution: "corretto" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Maven Verify | ||||||||||||||||||||||
| - name: Maven Verify | ||||||||||||||||||||||
| run: ./mvnw -B verify -DJAR_FILENAME=${{ env.JAR_FILENAME }} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Upload Artifact | ||||||||||||||||||||||
| - name: Upload Artifact | ||||||||||||||||||||||
| uses: actions/upload-artifact@v5 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| name: jar-artifact | ||||||||||||||||||||||
| path: ${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Docker Build | ||||||||||||||||||||||
| - name: Docker Build | ||||||||||||||||||||||
| shell: pwsh | ||||||||||||||||||||||
| run: docker build ` | ||||||||||||||||||||||
| -t ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }} ` | ||||||||||||||||||||||
| -f ${{ env.DOCKERFILE_PATH }} ` | ||||||||||||||||||||||
| --build-arg JAR_FILENAME=${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar ` | ||||||||||||||||||||||
|
Comment on lines
+59
to
+63
|
||||||||||||||||||||||
| shell: pwsh | |
| run: docker build ` | |
| -t ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }} ` | |
| -f ${{ env.DOCKERFILE_PATH }} ` | |
| --build-arg JAR_FILENAME=${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar ` | |
| shell: bash | |
| run: docker build \ | |
| -t ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }} \ | |
| -f ${{ env.DOCKERFILE_PATH }} \ | |
| --build-arg JAR_FILENAME=${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Job outputs cannot reference workflow-level environment variables using
env. The output value will be empty at runtime. Consider using a step output or directly referencingvars.CONTAINER_REGISTRYandvars.CONTAINER_REPOSITORYin the output expression.