diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml new file mode 100644 index 0000000..8cd36aa --- /dev/null +++ b/.github/workflows/deploy-staging.yaml @@ -0,0 +1,36 @@ +name: Staging Deployment + +on: + push: + branches: + - 'main' + +env: + IMAGE_NAME: ideagate-server-controller + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - id: commit + uses: prompt/actions-commit-hash@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.commit.outputs.short }} \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6b1b3b6..f96d6ff 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,9 +4,14 @@ on: push: branches: - '**' + - '!main' + +env: + IMAGE_NAME: ideagate-server-controller jobs: test: + name: Go Test runs-on: ubuntu-latest steps: @@ -35,6 +40,7 @@ jobs: run: go test ./... -v docker-image-build: + name: Build Docker Image runs-on: ubuntu-latest needs: test @@ -42,7 +48,19 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Build Docker image + - id: commit + uses: prompt/actions-commit-hash@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.commit.outputs.short }} + + - name: Get size of the image run: | - docker build -t server-controller:latest . - docker images server-controller:latest --format "Image Size: {{.Size}}" \ No newline at end of file + docker images ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.commit.outputs.short }} --format "Image Size: {{.Size}}" \ No newline at end of file