-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f82aeb
commit ef92ebf
Showing
1 changed file
with
13 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,54 +15,54 @@ env: | |
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
image_tag: ${{ steps.get-image-tag.outputs.image_tag }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Get short commit SHA | ||
id: get-image-tag | ||
run: echo "image_tag=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Log in to Azure Container Registry | ||
uses: azure/docker-login@v2 | ||
with: | ||
login-server: ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }} | ||
username: ${{ env.AZURE_CONTAINER_REGISTRY_USERNAME }} | ||
password: ${{ env.AZURE_CONTAINER_REGISTRY_PASSWORD }} | ||
|
||
- name: Create .env file from secret | ||
run: echo "${{ secrets.PROJECT_SECRET }}" > .env | ||
|
||
- name: Build and tag Docker image | ||
run: | | ||
docker build -f config/docker/Dockerfile -t ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:latest . | ||
docker tag ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:latest ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:${{ env.IMAGE_TAG }} | ||
- name: Push Docker image to ACR | ||
run: | | ||
docker push ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:latest | ||
docker push ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:${{ env.IMAGE_TAG }} | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build-and-push | ||
|
||
steps: | ||
- name: Log in to Azure Container Registry | ||
uses: azure/docker-login@v2 | ||
with: | ||
login-server: ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }} | ||
username: ${{ env.AZURE_CONTAINER_REGISTRY_USERNAME }} | ||
password: ${{ env.AZURE_CONTAINER_REGISTRY_PASSWORD }} | ||
|
||
- name: Pull and deploy the pinned Docker image | ||
run: | | ||
docker pull ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:${{ needs.build-and-push.outputs.image_tag }} | ||
docker run -d --name ${{ env.APP_NAME }} --restart always -p 8000:8000 ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:${{ needs.build-and-push.outputs.image_tag }} | ||
docker pull ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:latest | ||
docker run -d --name ${{ env.APP_NAME }} --restart always -p 8000:8000 ${{ env.AZURE_CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.APP_NAME }}:latest |