Skip to content

Update main.yml

Update main.yml #50

Workflow file for this run

name: Docker image CI
on:
push:
branches: ['dynamic_repo']
env:
IMAGE_TAG: latest
REPO_URL: ${{ github.repository }}
BASE_REF: ${{ github.base_ref }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Extract branch name
id: extract_branch
run: echo "BRANCH_NAME=$(basename ${{ github.ref }})" >> $GITHUB_ENV
- name: build Docker image
run: |
docker build . --tag ghcr.io/${{ env.REPO_URL }}:${{ env.IMAGE_TAG }}-${BRANCH_NAME}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image to GitHub Container Registry
run: |
docker push ghcr.io/${{ env.REPO_URL }}:${{ env.IMAGE_TAG }}-${BRANCH_NAME}