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: Build, Push Docker Image, Deploy, and Restart | |
on: | |
push: | |
branches: | |
- main # Triggers on changes to the main branch | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up Docker Buildx for building images | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Step 3: Log in to Docker Hub using credentials stored in GitHub secrets | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: jitenky | |
password: ${{ secrets.DOKER_TOKEN }} | |
# Step 4: Build and tag the Docker image | |
- name: Build and tag Docker image | |
run: | | |
docker build -t jitenky/career-craft:latest . | |
# Step 5: Push the Docker image to Docker Hub | |
- name: Push Docker image to Docker Hub | |
run: | | |
docker push jitenky/career-craft:latest | |
restart: | |
permissions: | |
id-token: write | |
contents: none | |
runs-on: ubuntu-latest | |
needs: build-and-push | |
steps: | |
# Step 1: Log in to Azure CLI | |
- name: Login to Azure CLI | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} # This should be a JSON object containing your credentials | |
# Step 2: Restart the Azure Web App | |
- name: Restart Azure Web App | |
uses: azure/cli@v2 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
az webapp restart --name st-sih-1134 --resource-group sih-ps |