diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml new file mode 100644 index 0000000..a30b929 --- /dev/null +++ b/.github/workflows/docker-build-and-push.yml @@ -0,0 +1,40 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + # Schedule for automatic builds: + # schedule: + - cron: '0 0 * * *' # Every day at midnight UTC + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: | + /tmp/.buildx-cache + /tmp/.buildkit + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build Docker image + run: | + docker buildx build --push --tag hanisntsolo/codeforces-lamp:latest . + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }}