Docker #113
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: Docker # Name of the workflow | |
| on: | |
| push: | |
| branches: [ docker-deploy/** ] | |
| workflow_run: | |
| workflows: [Webhook Store Test] | |
| types: [completed] | |
| branches: [main] # Workflow to run only when changes are made to `main` branch | |
| env: | |
| REGISTRY: docker.io # Image registry, ghcr.io incase of GitHub Container Registry | |
| IMAGE_NAME: openwebhook/webhook-store # Name of the image comes from the repository name | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest # GitHub Runner OS | |
| steps: | |
| - name: Checkout source code # Checksout the repository in the GitHub runner | |
| uses: 'actions/checkout@v3' | |
| with: | |
| ref: ${{ github.ref }} | |
| submodules: true | |
| fetch-depth: 0 | |
| - name: Git Semantic Version | |
| id: version-bump | |
| uses: PaulHatch/semantic-version@v5.0.0-alpha2 | |
| with: | |
| bump_each_commit: true | |
| - name: Output Step # Optional: Prints the new version | |
| env: | |
| NEW_TAG: ${{ steps.version-bump.outputs.version }} | |
| run: echo "new tag $NEW_TAG" | |
| - name: Log into registry ${{ env.REGISTRY }} # Log into the container registry from GitHub runner | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} # Uses the env defined above | |
| username: ${{ secrets.DOCKER_USERNAME }} # GitHub Secret added to the repository | |
| password: ${{ secrets.DOCKER_PASSWORD }} # GitHub Secret added to the repository | |
| - name: Build and push Docker image # Builds and pushes the image to the conatiner registry | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: ./ # Folder where the Dockerfile resides, use `/` if in root path | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ env.IMAGE_NAME }}:latest, ${{ env.IMAGE_NAME }}:${{ steps.version-bump.outputs.version }} | |
| # Pushed the image with `latest` tag and the new semantic version obtained from the version-bump step |