From 3b58270e51cb15c0ccbda1b90207272d4b4d0b41 Mon Sep 17 00:00:00 2001 From: Bagas Aulia Rezki Date: Sun, 8 Sep 2024 17:38:03 +0700 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3850c3b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Docker Build and Push + +on: + push: + branches: + - main + - staging + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/filekeeper:${{ github.ref_name }} + ${{ secrets.DOCKERHUB_USERNAME }}/filekeeper:latest + if: github.ref == 'refs/heads/main' + + - name: Build and push Docker image for staging + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/filekeeper:staging + if: github.ref == 'refs/heads/staging'