Publish Docker image to GitHub Packages #7
Workflow file for this run
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: Publish Docker image to GitHub Packages | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| tags: | |
| - "*" | |
| workflow_dispatch: | |
| jobs: | |
| publish-to-ghcr: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from tag and set lowercase repo owner | |
| id: extract_version | |
| run: | | |
| REF_NAME=${GITHUB_REF#refs/tags/} | |
| VERSION=${REF_NAME#v} | |
| REPO_OWNER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]') | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "repo_owner=$REPO_OWNER" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| env: | |
| VERSION: ${{ steps.extract_version.outputs.version }} | |
| REPO_OWNER: ${{ steps.extract_version.outputs.repo_owner }} | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64/v8 | |
| tags: | | |
| ghcr.io/${{ env.REPO_OWNER }}/etherproxy:${{ env.VERSION }} | |
| ghcr.io/${{ env.REPO_OWNER }}/etherproxy:latest | |
| labels: | | |
| org.opencontainers.image.version=${{ env.VERSION }} | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} |