diff --git a/.github/workflows/publish-ghcr.yaml b/.github/workflows/publish-ghcr.yaml new file mode 100644 index 0000000..e9ed7d8 --- /dev/null +++ b/.github/workflows/publish-ghcr.yaml @@ -0,0 +1,33 @@ +name: hedgeapp backend + +on: + push: + branches: [master, develop] + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_PAT }} + + - name: Set image tag + run: | + if [[ $GITHUB_REF == refs/heads/master ]]; then + IMAGE_TAG=latest + elif [[ $GITHUB_REF == refs/heads/develop ]]; then + IMAGE_TAG=develop + fi + echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV + + - name: Build and push docker image + run: | + docker build --tag ghcr.io/szarbartosz/hedgeapp-back:$IMAGE_TAG + docker push ghcr.io/szarbartosz/hedgeapp-back:$IMAGE_TAG