Skip to content

Commit

Permalink
Update pr.yaml (#2475)
Browse files Browse the repository at this point in the history
* Update pr.yaml

* Update pr.yaml
  • Loading branch information
vietanhduong authored Mar 4, 2024
1 parent b733687 commit 4f5ef67
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:

jobs:
prepare:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
current_branch: ${{ steps.current_branch.outputs.value }}
head_sha: ${{ github.event.pull_request.head.sha }}
Expand All @@ -26,7 +26,7 @@ jobs:
pr_number: ${{github.event.number}}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Extract branch
shell: bash
Expand All @@ -48,65 +48,67 @@ jobs:
REF_BRANCH=${REF/refs\/tags\//}
BRANCH=$REF_BRANCH
fi
echo "::set-output name=value::$BRANCH"
echo "name=$BRANCH" >> $GITHUB_OUTPUT
- name: Extract GitHub HEAD SHA
id: head_sha
run: echo "::set-output name=value::$(git rev-parse HEAD)"
run: |
echo "value=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Get Docker image tag
id: get_tag
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
short_sha="$(echo $HEAD_SHA | head -c7)"
echo "::set-output name=image_tag::adpr-$short_sha"
echo "image_tag=adpr-$short_sha" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- prepare
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 20.9.0
registry-url: 'https://npm.pkg.github.com'
scope: '@kybernetwork'
token: ${{ secrets.GH_PAT }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master

- name: Gcloud Auth
uses: google-github-actions/auth@v0
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCR_CREDENTIALS }}'

- name: Setup Gcloud SDK
uses: google-github-actions/setup-gcloud@v0
uses: google-github-actions/setup-gcloud@v1

- name: Configure docker
run: gcloud auth configure-docker

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ env.SERVICE }}-buildx

- name: Restore node_modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependences
uses: bahmutov/npm-install@HEAD
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT }} ### authen npm
uses: bahmutov/npm-install@v1

- name: Yarn Build
env:
Expand All @@ -117,7 +119,7 @@ jobs:
run: yarn build-prod

- name: Docker build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand All @@ -137,12 +139,14 @@ jobs:
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
linter:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- prepare
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT }} ### authen npm
steps:
- name: Check out Git repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v1
Expand All @@ -152,9 +156,7 @@ jobs:
scope: '@kybernetwork'

- name: Install dependences
uses: bahmutov/npm-install@HEAD
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT }} ### authen npm
uses: bahmutov/npm-install@v1

- name: Run Lint
run: yarn lint --quiet

0 comments on commit 4f5ef67

Please sign in to comment.