From 8980b3dab876496e00312473cfa48df945cc1d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Ravent=C3=B3s=20Calle?= <31952499+RCRoger@users.noreply.github.com> Date: Sat, 10 Feb 2024 13:20:24 +0100 Subject: [PATCH] Update docker-image.yml --- .github/workflows/docker-image.yml | 39 ++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d131eac58..4392a29aa 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,18 +1,37 @@ -name: Docker Image CI +name: Build and Push Docker Image on: push: - branches: [ "development" ] - pull_request: - branches: [ "development" ] + branches: + - development + - master jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check Out Repository + uses: actions/checkout@v2 - build: + - name: Build Project + run: | + npm install + npm run build - runs-on: ubuntu-latest + - name: Log in to GitHub Container Registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag roger-ghostfolio:$(date +%s) + - name: Build Docker image + run: | + REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') + BRANCH_NAME=$(echo ${{ github.ref_name }} | tr '[:upper:]' '[:lower:]') # Get the branch name in lowercase + docker build . -t ghcr.io/$REPO_LOWER/portfolio:$BRANCH_NAME + + - name: Push Docker image to GitHub Packages + run: | + REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') + BRANCH_NAME=$(echo ${{ github.ref_name }} | tr '[:upper:]' '[:lower:]') # Get the branch name in lowercase + docker push ghcr.io/$REPO_LOWER/$REPO_LOWER:$BRANCH_NAME