-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (43 loc) · 2.18 KB
/
deploy-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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