From 2da2067457d352335ae7d613db38834eca2512fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Kri=C5=BEi=C4=87?= Date: Tue, 30 Apr 2024 16:11:41 +0200 Subject: [PATCH] Add pipeline --- .github/dependabot.yaml | 14 +++++++++++++ .github/workflows/build.yml | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/build.yml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..0c2ab4d --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'daily' + - package-ecosystem: 'gomod' + directory: '/' + schedule: + interval: 'daily' + - package-ecosystem: 'docker' + directory: '/' + schedule: + interval: 'daily' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bed693f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + tags: + - 'v*' + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build the Docker image + run: docker build . --file Dockerfile --tag ghcr.io/prodyna/delete-from-enterprise:latest + + # if tag, get the tag as variable + - name: Get tag if available + if: startsWith(github.ref, 'refs/tags/v') + run: echo "tag=${GITHUB_REF#refs/tags/*}" >> $GITHUB_ENV + + # Login to the GitHub Container Registry + - name: Login to the GitHub Container Registry + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} + + # Push latest to GitHub Container Registry + - name: Push the latest Docker image to the GitHub Container Registry + run: docker push ghcr.io/prodyna/delete-from-enterprise:latest + + # if tagged, push the image to the GitHub Container Registry + - name: Push the tagged Docker image to the GitHub Container Registry + if: startsWith(github.ref, 'refs/tags/v') + run: | + docker tag ghcr.io/prodyna/delete-from-enterprise:latest ghcr.io/prodyna/delete-from-enterprise:${{ env.tag }} + docker push ghcr.io/prodyna/delete-from-enterprise:${{ env.tag }}