Init github actions #20
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: Node.js CI | |
on: | |
push: | |
branches: [ "main", "actions_init" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: setup-node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 18.14 | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: install dependencies | |
run: npm ci | |
- name: check build errors | |
run: npm run build | |
- name: check test if exsists | |
run: npm test --if-present | |
push_to_registry: | |
name: login, build and push docker image to docker hub | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: create tag | |
run: echo "CURRENT_DATE=$(date +%s)" >> $GITHUB_ENV | |
- name: Set env | |
run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./Dockerfile | |
context: . | |
push: true | |
tags: arkadiuszkurylo/aexol-shop-backend:${{ env.GITHUB_SHA_SHORT }}-${{ env.CURRENT_DATE }} |