From 3e68756d6bb0c063f46f7e77cd7660b62344e75b Mon Sep 17 00:00:00 2001 From: liyh42 Date: Tue, 13 Aug 2024 15:34:26 +0800 Subject: [PATCH] update .github actions --- .github/workflows/docker-image.yml | 22 ++++++++++++++-------- .gitignore | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3f53646..5d13558 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,18 +1,24 @@ -name: Docker Image CI +name: Build and Push Docker Image to Docker Hub on: push: branches: [ "main" ] - pull_request: - branches: [ "main" ] jobs: - build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + + - name: login to docker registry + uses: docker/login-action@v3 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_TOKEN}} + + - name: build and push docker image to registry + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: alvinleee/github-action-test:latest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp