test auto update #51
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: Create and publish Docker images | |
on: | |
push: | |
branches: | |
- main | |
# tags: | |
# - 'v*' | |
env: | |
REGISTRY: rtwcr1.azurecr.io | |
REGISTRY_USERNAME: GitHub-Action | |
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
service: [frontend, services/auth-service, services/analytics-service, services/heatmap-service, services/pin-service, services/update-service] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Filter changes | |
uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
service: | |
- '${{ matrix.service }}/version.txt' | |
- name: Set version environment variable | |
if: steps.changes.outputs.service == 'true' | |
run: | | |
VER=$(cat ${{ matrix.service }}/version.txt) | |
echo "VERSION=$VER" >> $GITHUB_ENV | |
- name: Log in to the Container registry | |
if: steps.changes.outputs.service == 'true' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ env.REGISTRY_USERNAME }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
- name: Build and push Docker image (${{ matrix.service }}) | |
if: steps.changes.outputs.service == 'true' | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.service }} | |
push: true | |
tags: | | |
${{ env.REGISTRY }}/${{ matrix.service }}:latest | |
${{ env.REGISTRY }}/${{ matrix.service }}:${{ env.VERSION }} | |
apply-images-service: | |
needs: build-and-push-image | |
runs-on: self-hosted | |
strategy: | |
fail-fast: false | |
matrix: | |
service: [auth-service, analytics-service, heatmap-service, pin-service, update-service] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Filter changes | |
uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
service: | |
- 'service/${{ matrix.service }}/version.txt' | |
- name: Azure login | |
if: steps.changes.outputs.service == 'true' | |
uses: azure/login@v1 | |
with: | |
auth-type: IDENTITY | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Kubernetes deploy new images | |
if: steps.changes.outputs.service == 'true' | |
working-directory: deployement/k8s | |
run: | | |
az aks get-credentials --resource-group ${{ secrets.AKS_RESOURCE_GROUP_NAME }} --name ${{ secrets.KUBERNETES_CLUSTER_NAME }} | |
kubectl rollout restart deployment ${{ matrix.service }} | |
apply-images-frontend: | |
needs: build-and-push-image | |
runs-on: self-hosted | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Filter changes | |
uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
service: | |
- 'frontend/version.txt' | |
- name: Azure login | |
if: steps.changes.outputs.service == 'true' | |
uses: azure/login@v1 | |
with: | |
auth-type: IDENTITY | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Kubernetes deploy new images | |
if: steps.changes.outputs.service == 'true' | |
working-directory: deployement/k8s | |
run: | | |
az aks get-credentials --resource-group ${{ secrets.AKS_RESOURCE_GROUP_NAME }} --name ${{ secrets.KUBERNETES_CLUSTER_NAME }} | |
ls | grep "frontend" | xargs -L 1 -d '\n' basename -s '.yaml' | xargs -L 1 -d '\n' kubectl rollout restart deployment |