Merge pull request #97 from rasikaghadge/rasika #18
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: Project Image Push | |
on: | |
push: | |
branches: ["main", "suraj"] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log into registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker images | |
run: docker-compose -f docker-compose.yml build | |
working-directory: . | |
- name: Extract Docker metadata for backend | |
id: backend-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }}/backend | |
- name: Push backend Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./server | |
push: true | |
tags: ${{ steps.backend-meta.outputs.tags }} | |
- name: Extract Docker metadata for frontend | |
id: frontend-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }}/frontend | |
- name: Push frontend Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./client | |
push: true | |
tags: ${{ steps.frontend-meta.outputs.tags }} | |
- name: Sign the published Docker images | |
run: | | |
echo "${{ steps.backend-meta.outputs.tags }}" | xargs -I {} cosign sign --yes ghcr.io/${{ github.repository }}/backend:{}@${{ steps.backend-meta.outputs.digest }} | |
echo "${{ steps.frontend-meta.outputs.tags }}" | xargs -I {} cosign sign --yes ghcr.io/${{ github.repository }}/frontend:{}@${{ steps.frontend-meta.outputs.digest }} | |
if: ${{ github.event_name != 'pull_request' }} |