Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/cd-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# - uses: actions/checkout@v6
# - uses: actions/setup-node@v6
# with:
# node-version: 16
# cache: 'npm'
Expand All @@ -23,7 +23,7 @@ jobs:
# run: |
# npm ci
# npm run build --if-present
# - uses: actions/upload-artifact@v3
# - uses: actions/upload-artifact@v6
# with:
# name: build-code
# path: hangman-api/dist/
Expand All @@ -33,15 +33,15 @@ jobs:
needs: build

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/checkout@v6
- uses: actions/download-artifact@v7
with:
name: build-code
path: hangman-api/dist/
- name: Build and Push Docker Image
working-directory: ./hangman-api
env:
DOCKER_USER: "jaimesalas"
DOCKER_USER: "jaimesalas" # <your-docker-username>
DOCKER_REPOSITORY: "hangman-api"
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/cd-using-docker-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Docker Image hangman API CD (using Docker actions)

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 16
cache: 'npm'
cache-dependency-path: hangman-api/package-lock.json
- name: build
working-directory: ./hangman-api
run: |
npm ci
npm run build --if-present
- uses: actions/upload-artifact@v6
with:
name: build-code
path: hangman-api/dist/

# delivery:
# runs-on: ubuntu-latest
# needs: build

# steps:
# - uses: actions/checkout@v6
# - uses: actions/download-artifact@v7
# with:
# name: build-code
# path: hangman-api/dist/
# - name: Build and Push Docker Image
# working-directory: ./hangman-api
# env:
# DOCKER_USER: "jaimesalas" # <your-docker-username>
# DOCKER_REPOSITORY: "hangman-api"
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# run: |
# echo $DOCKER_PASSWORD | docker login --username $DOCKER_USER --password-stdin
# image=$DOCKER_USER/$DOCKER_REPOSITORY:$(date +%s)
# docker build -t $image -f Dockerfile.workflow .
# docker push $image

delivery:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Download dist folder as artifact
uses: actions/download-artifact@v7
- name: Docker Hub login
uses: docker/login-action@v3
with:
# registry: by default is set to Docker Hub
username: jtrillo # <your_docker_username>
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker Image
uses: docker/build-push-action@v6
with:
context: ./hangman-api
push: true
tags: jtrillo/hangman-api-actions:latest # <your_docker_username>
file: ./hangman-api/Dockerfile.workflow
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 16
cache: "npm"
Expand All @@ -32,8 +32,8 @@ jobs:
needs: build

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 16
- name: test
Expand Down Expand Up @@ -63,8 +63,8 @@ jobs:
- 5432:5432

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 16
# - name: Create database relationships
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable-node-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
Expand All @@ -26,7 +26,7 @@ jobs:
run: |
npm ci
npm run build --if-present
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v6
with:
name: build-code
path: ${{ inputs.working-directory }}/dist/
3 changes: 2 additions & 1 deletion .github/workflows/test-custom-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
uses: jtrillo/[email protected]
with:
commodity: silver
currency: EUR
# Use the output from 'commodity_price' step
- name: Get the output price
run: echo "Price per ounce is ${{ steps.commodity_price.outputs.price }} USD"
run: echo "Price per ounce is ${{ steps.commodity_price.outputs.price }} ${{ steps.commodity_price.inputs.currency }}"
3 changes: 1 addition & 2 deletions .start-code/hangman-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ ENV NODE_ENV=production

RUN npm install


CMD ["npm", "start"]
CMD ["npm", "start"]
15 changes: 5 additions & 10 deletions 01-setup-ci/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
whoami
pwd
node -v


```

Let's commit this file to a new branch:
Expand Down Expand Up @@ -84,7 +82,7 @@ jobs:

steps:
+ - name: Checkout # This field is optional
+ - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
- name: inspect
run: |
ls -al
Expand All @@ -94,7 +92,7 @@ jobs:

```

Recall that on job steps we can use an action or run a command. Here we're using an action `actions/checkout@v4` that needs no further configuration.
Recall that on job steps we can use an action or run a command. Here we're using an action `actions/checkout@v6` that needs no further configuration.

```bash
git add .
Expand Down Expand Up @@ -142,14 +140,13 @@ jobs:
- runs-on: ubuntu-latest

- steps:
- - uses: actions/checkout@v4
- - uses: actions/checkout@v6
- - name: inspect
- run: |
- ls -al
- whoami
- pwd
- node -v

```

```yaml
Expand All @@ -167,7 +164,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: build and test
working-directory: ./hangman-api
run: |
Expand Down Expand Up @@ -204,15 +201,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: build and test
working-directory: ./hangman-api
run: |
npm ci
npm run build --if-present
ls ./dist
npm test

```

* With `paths` we filter the directories that are able to trigger a new workflow.
Expand Down
10 changes: 5 additions & 5 deletions 02-multiple-target-environments/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
node-version: [16, 17, 18]
# diff #
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: build and test
working-directory: ./hangman-api
run: |
Expand All @@ -60,10 +60,10 @@ jobs:
node-version: [16, 17, 18]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# diff #
- name: Setup Node.js environment
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
# diff #
Expand Down Expand Up @@ -132,9 +132,9 @@ jobs:
+ os: [ubuntu-20.04, ubuntu-22.04]
+ runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Setup Node.js environment
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: build and test
Expand Down
14 changes: 7 additions & 7 deletions 03-running-multiple-jobs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ jobs:
- runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- - name: Setup Node.js environment
- uses: actions/setup-node@v4
- uses: actions/setup-node@v6
- with:
- node-version: ${{ matrix.node-version }}
- name: build and test
Expand All @@ -68,7 +68,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- - name: build and test
+ - name: build
working-directory: ./hangman-api
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: build
working-directory: ./hangman-api
run: |
Expand All @@ -109,7 +109,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: test
working-directory: ./hangman-api
run: |
Expand Down Expand Up @@ -188,7 +188,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: build
working-directory: ./hangman-api
run: |
Expand All @@ -199,7 +199,7 @@ jobs:
runs-on: ubuntu-latest
+ needs: build # If it depends on more than one, use an array
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: test
working-directory: ./hangman-api
run: |
Expand Down
Loading