From 31efa2c43c26970e1c2ddf10871fe6373bbc8de2 Mon Sep 17 00:00:00 2001 From: Lifailon Date: Mon, 31 Mar 2025 10:04:15 +0300 Subject: [PATCH] add cd for docker hub --- .github/workflows/deploy.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..73ebbe3 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,31 @@ +name: CD Docker Hub + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Get version + run: | + version=$(go run main.go -v) + echo "Current version: $version" + echo "ARTIFACT_VERSION=$version" >> $GITHUB_ENV + + - name: Build and push Docker image + run: | + docker build -t lifailon/lazyjournal:${{ env.ARTIFACT_VERSION }} . + docker push lifailon/lazyjournal:${{ env.ARTIFACT_VERSION }} + env: + ARTIFACT_VERSION: ${{ env.ARTIFACT_VERSION }} \ No newline at end of file