github: push image to GHCR in addition to Docker Hub #65
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: Push OpenSIPS Control Panel Image to Docker Hub and GHCR | |
| on: | |
| push: | |
| repository_dispatch: | |
| types: [OpenSIPS CP trigger] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2.1.0 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_TOKEN }} | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v2.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Determine tag | |
| run: | | |
| if [ "${{ github.event_name }}" == "repository_dispatch" ]; then | |
| echo "BRANCH=${{ github.event.client_payload.branch && github.event.client_payload.branch || 'master' }}" >> $GITHUB_ENV | |
| echo "DOCKER_TAG=${{ github.event.client_payload.docker_tag }}" >> $GITHUB_ENV | |
| else | |
| echo "DOCKER_TAG=latest" >> $GITHUB_ENV | |
| echo "BRANCH=master" >> $GITHUB_ENV | |
| fi | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| build-args: | | |
| OPENSIPS_CP_VERSION=${{ env.BRANCH }} | |
| push: true | |
| tags: | | |
| opensips/opensips-cp:${{ env.DOCKER_TAG }} | |
| ghcr.io/opensips/opensips-cp:${{ env.DOCKER_TAG }} |