Skip to content

Commit

Permalink
fix: Add additional tags for prod, add test step and some basic cachi…
Browse files Browse the repository at this point in the history
…ng (#314)
  • Loading branch information
BenjaminMichaelis committed Dec 11, 2023
1 parent 6d11128 commit a92d4fe
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/Build-Test-And-Deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
environment: 'BuildAndUploadImage'
env:
TEST_TAG: user/app:test

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -55,12 +57,14 @@ jobs:
if: github.event_name != 'pull_request_target'
uses: docker/build-push-action@v5
with:
tags: ${{ vars.CONTAINER_REGISTRY }}/essentialcsharpweb:${{ github.sha }},${{ vars.CONTAINER_REGISTRY }}/essentialcsharpweb:latest
tags: ${{ vars.DEVCONTAINER_REGISTRY }}/essentialcsharpweb:${{ github.sha }},${{ vars.DEVCONTAINER_REGISTRY }}/essentialcsharpweb:latest,${{ vars.PRODCONTAINER_REGISTRY }}/essentialcsharpweb:${{ github.sha }},${{ vars.PRODCONTAINER_REGISTRY }}/essentialcsharpweb:latest
file: ./EssentialCSharp.Web/Dockerfile
context: .
secrets: |
"nuget_auth_token=${{ secrets.AZURE_DEVOPS_PAT }}"
outputs: type=docker,dest=${{ github.workspace }}/essentialcsharpwebimage.tar
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -97,26 +101,27 @@ jobs:
if: github.event_name != 'pull_request_target'
uses: docker/login-action@v3
with:
registry: ${{ vars.CONTAINER_REGISTRY }}
registry: ${{ vars.DEVCONTAINER_REGISTRY }}
username: ${{ secrets.ESSENTIALCSHARPDEV_CLIENT_ID }}
password: ${{ secrets.ESSENTIALCSHARPDEV_CLIENT_SECRET }}

- name: Push Image to Container Registry
if: github.event_name != 'pull_request_target'
run: docker push --all-tags ${{ vars.CONTAINER_REGISTRY }}/essentialcsharpweb
run: docker push --all-tags ${{ vars.DEVCONTAINER_REGISTRY }}/essentialcsharpweb

- name: Create and Deploy to containerapp
if: github.event_name != 'pull_request_target'
uses: azure/CLI@v1
env:
CONTAINER_APP_NAME: ${{ vars.CONTAINER_APP_NAME }}
RESOURCEGROUP: ${{ vars.RESOURCEGROUP }}
CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
CONTAINER_REGISTRY: ${{ vars.DEVCONTAINER_REGISTRY }}
CONTAINER_APP_ENVIRONMENT: ${{ vars.CONTAINER_APP_ENVIRONMENT }}
with:
inlineScript: |
az config set extension.use_dynamic_install=yes_without_prompt
az containerapp up -n $CONTAINER_APP_NAME -g $RESOURCEGROUP --image $CONTAINER_REGISTRY/essentialcsharpweb:${{ github.sha }} --environment $CONTAINER_APP_ENVIRONMENT --registry-server $CONTAINER_REGISTRY
az containerapp up -n $CONTAINER_APP_NAME -g $RESOURCEGROUP --image $CONTAINER_REGISTRY/essentialcsharpweb:${{ github.sha }} --environment $CONTAINER_APP_ENVIRONMENT --registry-server $CONTAINER_REGISTRY --ingress external
az containerapp ingress update -n $CONTAINER_APP_NAME -g $RESOURCEGROUP --type external
- name: Logout of Azure CLI
if: 'always()'
Expand Down Expand Up @@ -165,25 +170,26 @@ jobs:
if: github.event_name != 'pull_request_target'
uses: docker/login-action@v3
with:
registry: ${{ vars.CONTAINER_REGISTRY }}
registry: ${{ vars.PRODCONTAINER_REGISTRY }}
username: ${{ secrets.ESSENTIALCSHARP_CLIENT_ID }}
password: ${{ secrets.ESSENTIALCSHARP_CLIENT_SECRET }}

- name: Push Image to Container Registry
if: github.event_name != 'pull_request_target'
run: docker push --all-tags ${{ vars.CONTAINER_REGISTRY }}/essentialcsharpweb
run: docker push --all-tags ${{ vars.PRODCONTAINER_REGISTRY }}/essentialcsharpweb

- name: Create and Deploy to containerapp
uses: azure/CLI@v1
env:
CONTAINER_APP_NAME: ${{ vars.CONTAINER_APP_NAME }}
RESOURCEGROUP: ${{ vars.RESOURCEGROUP }}
CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
CONTAINER_REGISTRY: ${{ vars.PRODCONTAINER_REGISTRY }}
CONTAINER_APP_ENVIRONMENT: ${{ vars.CONTAINER_APP_ENVIRONMENT }}
with:
inlineScript: |
az config set extension.use_dynamic_install=yes_without_prompt
az containerapp up -n $CONTAINER_APP_NAME -g $RESOURCEGROUP --image $CONTAINER_REGISTRY/essentialcsharpweb:${{ github.sha }} --environment $CONTAINER_APP_ENVIRONMENT --registry-server $CONTAINER_REGISTRY
az containerapp up -n $CONTAINER_APP_NAME -g $RESOURCEGROUP --image $CONTAINER_REGISTRY/essentialcsharpweb:${{ github.sha }} --environment $CONTAINER_APP_ENVIRONMENT --registry-server $CONTAINER_REGISTRY --ingress external
az containerapp ingress update -n $CONTAINER_APP_NAME -g $RESOURCEGROUP --type external
- name: Logout of Azure CLI
if: 'always()'
Expand Down

0 comments on commit a92d4fe

Please sign in to comment.