set up git auth in tag workflow #6
Workflow file for this run
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: Build Production Image | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Needed to fetch all tags | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Git | |
| run: | | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| - name: Update latest tag on Github | |
| run: | | |
| git tag -f latest | |
| git push origin latest -f | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract version from tag | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Create .env file from secret | |
| run: echo "${{ secrets.PRODUCTION_ENV_FILE }}" > .env | |
| - name: Build and push | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| push: true | |
| build-args: | | |
| ENVIRONMENT=production | |
| tags: | | |
| peterrauscher/solesearch-api:latest | |
| peterrauscher/solesearch-api:${{ steps.get_version.outputs.VERSION }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |