Create docker-image.yml #1
This file contains 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 Image CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Git Semantic Version | |
uses: PaulHatch/[email protected] | |
with: | |
major_pattern: "major:" | |
minor_pattern: "feat:" | |
format: "${major}.${minor}.${patch}-prerelease${increment}" | |
id: version | |
- name: Docker Login | |
env: | |
DOCKER_USER: ${{ secrets.DOCKER_USER }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
run: | | |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | |
- name: Build Docker Image | |
env: | |
NEW_VERSION: ${{ steps.version.outputs.version }} | |
run: | | |
docker build -t yan640/recipes-api:$NEW_VERSION . | |
docker build -t yan640/recipes-api:latest . | |
- name: Push Docker Image | |
env: | |
NEW_VERSION: ${{ steps.version.outputs.version }} | |
run: | | |
docker push yan640/recipes-api:$NEW_VERSION | |
docker push yan640/recipes-api:latest | |