fix conditional #25
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: devops testing | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Custom input for tags' | |
required: false | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm install | |
- name: Run tests | |
run: npm test | |
docker: | |
runs-on: ubuntu-latest | |
#needs: test | |
steps: | |
- name: Set image tag | |
run: | | |
if [[ -z ${{inputs.tag}} ]]; then | |
echo "TAG is not provided, using latest" | |
echo "TAG=latest" >> $GITHUB_ENV | |
else | |
echo "TAG is provided, using ${{inputs.tag}}" | |
echo "TAG=${{inputs.tag}}" >> $GITHUB_ENV | |
fi | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USER }}/expertlab:${{ env.TAG }} | |