ci: refactored the composite action #7
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: Lint, Format, Build, and Push Docker Image | |
on: | |
push: | |
branches: | |
- master | |
env: | |
HUSKY: 0 | |
jobs: | |
lint-format-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install | |
- name: Run Prettier | |
run: npm run format | |
- name: Run ESLint | |
run: npm run lint:fix | |
env: | |
CI: true | |
- name: Run unit tests | |
run: npm run test:silent | |
env: | |
CI: true | |
# build-and-push: | |
# runs-on: ubuntu-latest | |
# needs: lint-format-test | |
# steps: | |
# - name: Checkout code | |
# uses: actions/checkout@v3 | |
# - name: Log in to Docker | |
# run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ vars.DOCKER_USERNAME }} --password-stdin | |
# - name: Build Docker image | |
# run: | | |
# VERSION=$(git rev-list --count HEAD) | |
# docker build -t ${{ vars.DOCKER_REGISTRY }}/snappy-notes:${VERSION}.0 . | |
# - name: Push Docker image | |
# run: | | |
# VERSION=$(git rev-list --count HEAD) | |
# docker push ${{ vars.DOCKER_REGISTRY }}/snappy-notes:${VERSION}.0 | |
build-and-push: | |
needs: lint-format-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Build and Push Docker Image | |
uses: ./.github/actions/docker-build-push | |
with: | |
docker_username: ${{ vars.DOCKER_USERNAME }} | |
docker_password: ${{ secrets.DOCKER_PASSWORD }} | |
docker_registry: ${{ vars.DOCKER_REGISTRY }} | |
repository: snappy-notes |