diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d3065b5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: Build devtasker docker image + +on: + pull_request: + branches: + - master + paths-ignore: + - '*.md' + - .gitignore + - '**/docs/**' + push: + branches: + - master + - '**/ci**' + paths-ignore: + - '*.md' + - .gitignore + - '**/docs/**' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Docker Hub Authentication + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Generate Docker tag + id: tag + run: | + if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + echo "tag=latest" >> $GITHUB_OUTPUT + else + echo "tag=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT + fi + + - name: Build and Push Docker Image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/README.md b/README.md index 708aa16..7023015 100644 --- a/README.md +++ b/README.md @@ -16,5 +16,6 @@ These are things that I want to implement here. - [ ] Unit Testing - [x] Monitoring (prometheus) - [x] Docker +- [x] CI/CD - [ ] GraphQL API - [ ] gRPC Layer