chore: update Docker workflow to use secrets

- Change hardcoded Docker Hub username to use secrets
- Update workflow to securely reference DockerHub credentials

This update enhances the security of the GitHub Actions workflow
by using secrets instead of exposing sensitive information
in the codebase. This ensures that the Docker Hub username is
kept private and reduces the risk of accidental exposure.
This commit is contained in:
songtianlun 2025-01-22 00:47:33 +08:00
parent 54133b2f87
commit ec2c92e6c9

View File

@ -21,15 +21,15 @@ jobs:
VERSION="v${GIT_VERSION}" VERSION="v${GIT_VERSION}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "GIT_VERSION=${GIT_VERSION}" >> $GITHUB_ENV echo "GIT_VERSION=${GIT_VERSION}" >> $GITHUB_ENV
echo "LATEST_TAG=${{ env.REGISTRY }}/${{ vars.DOCKERHUB_USER }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT" echo "LATEST_TAG=${{ env.REGISTRY }}/${{ secrets.DOCKERHUB_USER }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT"
echo "VERSION_TAG=${{ env.REGISTRY }}/${{ vars.DOCKERHUB_USER }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT" echo "VERSION_TAG=${{ env.REGISTRY }}/${{ secrets.DOCKERHUB_USER }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT"
- -
name: Login to ${{ env.REGISTRY }} name: Login to ${{ env.REGISTRY }}
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
username: ${{ vars.DOCKERHUB_USER }} username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Set up QEMU name: Set up QEMU