CI/CD Workflow #120
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: CI/CD Workflow | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
schedule: | |
- cron: '21 18 * * 3' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract branch name | |
id: extract_branch | |
run: echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})" | |
- name: Build Docker image | |
run: docker build --target prod -t onboardlite:${{ steps.extract_branch.outputs.branch }} . | |
- name: Tag Docker image | |
run: docker tag onboardlite:${{ steps.extract_branch.outputs.branch }} ghcr.io/hackucf/onboardlite:${{ steps.extract_branch.outputs.branch }} | |
- name: Push Docker image | |
run: docker push ghcr.io/hackucf/onboardlite:${{ steps.extract_branch.outputs.branch }} |