patch docker login #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to GitHub Container Registry | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Get version from version.py | |
| id: get_version | |
| run: | | |
| VERSION=$(python -c "from utils.version import __version__; print(__version__)") | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| echo "Docker tag version: $VERSION" | |
| - name: Build Docker image | |
| run: | | |
| docker build -t ghcr.io/${{ github.repository_owner }}/pyproxy:${{ env.VERSION }} -t ghcr.io/${{ github.repository_owner }}/pyproxy:latest . | |
| - name: Push Docker image | |
| run: | | |
| docker push ghcr.io/${{ github.repository_owner }}/pyproxy:${{ env.VERSION }} | |
| docker push ghcr.io/${{ github.repository_owner }}/pyproxy:latest |