From b1ff2266065a0253ed8e9cb3a731bb6dfc0c2323 Mon Sep 17 00:00:00 2001 From: modagent Date: Fri, 6 Dec 2024 15:27:53 -0500 Subject: [PATCH] publish container --- .github/workflows/publish.yaml | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..23fe869 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,47 @@ +name: Publish to GitHub Container Registry + +on: + push: + branches: + - master + - main + - publish_container + +permissions: + contents: read + packages: write + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout code + - name: Checkout Code + uses: actions/checkout@v3 + + # Step 2: Log in to GitHub Container Registry + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Step 3: Set up repository name and organization + - name: Set up repository info + run: | + echo "REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + echo "ORG_NAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + # Step 4: Build the Docker image + - name: Build Docker Image + run: | + echo "Building image: ghcr.io/${ORG_NAME}/${REPO_NAME}:latest" + docker build -t ghcr.io/${ORG_NAME}/${REPO_NAME}:latest . + + # Step 5: Push the Docker image + - name: Push Docker Image + run: | + echo "Pushing image: ghcr.io/${ORG_NAME}/${REPO_NAME}:latest" + docker push ghcr.io/${ORG_NAME}/${REPO_NAME}:latest \ No newline at end of file