Build and Push to ghcr and use prebuilt images #3
Workflow file for this run
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 and Push Docker Images | |
on: | |
pull_request: | |
branches: [main, develop] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Backend Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile | |
push: true | |
tags: ghcr.io/${{ github.repository }}/backend:latest | |
- name: Build and Push Frontend Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./frontend | |
file: ./frontend/Dockerfile | |
push: true | |
tags: ghcr.io/${{ github.repository }}/frontend:latest | |
- name: Set Backend Package Visibility to Public | |
run: | | |
curl \ | |
-X PATCH \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/user/packages/container/${{ github.repository }}/backend/visibility" \ | |
-d '{"visibility":"public"}' | |
- name: Set Frontend Package Visibility to Public | |
run: | | |
curl \ | |
-X PATCH \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/user/packages/container/${{ github.repository }}/frontend/visibility" \ | |
-d '{"visibility":"public"}' |