Deploy to production #48
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: Deploy to production | |
on: | |
create: | |
tags: | |
- collect-* | |
jobs: | |
push_to_docker_hub: | |
if: ${{ startsWith(github.ref, 'refs/tags/collect-') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # fetch all tags, default 1 | |
- name: Get the version | |
id: app_version | |
run: echo ::set-output name=APP_VERSION::$(git describe --always --tags) | |
- run: echo ${{ steps.app_version.outputs.APP_VERSION }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build Docker image and push to Docker Hub | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
${{ secrets.DOCKER_HUB_USERNAME }}/collect:latest | |
${{ secrets.DOCKER_HUB_USERNAME }}/collect:${{ steps.app_version.outputs.APP_VERSION }} |