6 create pipeline with docker deployment #7
Workflow file for this run
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: Pipeline | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
workflow_dispatch: | |
jobs: | |
publish-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: build docker image latest | |
run: | | |
VERSION=$(cat VERSION | tr -d ' \t\n\r') | |
cd docker | |
docker build . -t ${{ vars.DOCKER_HUB_USERNAME }}/backup:latest | |
- name: build docker image ${VERSION} | |
run: | | |
VERSION=$(cat VERSION | tr -d ' \t\n\r') | |
cd docker | |
docker build . -t ${{ vars.DOCKER_HUB_USERNAME }}/backup:${VERSION} | |
- name: skip if not main | |
if: contains('refs/heads/main', github.ref) | |
run: | | |
echo "skipping" | |
exit 0 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: push latest | |
run: | | |
docker push ${{ vars.DOCKER_HUB_USERNAME }}/backup:latest | |
env: | |
username: ${{ vars.DOCKER_HUB_USERNAME }} | |
- name: push ${VERSION} | |
run: | | |
VERSION=$(cat VERSION | tr -d ' \t\n\r') | |
docker push ${{ vars.DOCKER_HUB_USERNAME }}/backup:${VERSION} | |
env: | |
username: ${{ vars.DOCKER_HUB_USERNAME }} | |
publish-dockerhub-description: | |
if: contains('refs/heads/main', github.ref) | |
needs: | |
- publish-docker-image | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update Dockerhub description | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ vars.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
repository: ${{ vars.DOCKER_HUB_USERNAME }}/backup | |
readme-filepath: ./README.md |