From d6bd5d2f6da8d317ad842643ac5b12d7f56817e5 Mon Sep 17 00:00:00 2001 From: Sai charan Guntupalli <63032681+sai80082@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:42:39 +0530 Subject: [PATCH] Create pr-release.yml --- .github/workflows/pr-release.yml | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/pr-release.yml diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml new file mode 100644 index 0000000..4fda809 --- /dev/null +++ b/.github/workflows/pr-release.yml @@ -0,0 +1,33 @@ +name: Build and Tag Docker Image on PR + +on: + pull_request: + types: [opened, synchronize] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract PR number + id: pr-number + run: echo "PR_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV + + - name: Build and push Docker image + run: | + docker build --build-arg VERSION=pr-${{ env.PR_NUMBER }} \ + -t ghcr.io/${{ github.repository }}:pr-${{ env.PR_NUMBER }} . + docker push ghcr.io/${{ github.repository }}:pr-${{ env.PR_NUMBER }}