Skip to content

Merge pull request #2 from moontai0724/develop #2

Merge pull request #2 from moontai0724/develop

Merge pull request #2 from moontai0724/develop #2

Workflow file for this run

name: "CD: Deploy when pushes to main"
on:
push:
branches:
- main
jobs:
test-and-upload-coverage:
name: Test and Upload Coverage to Codecov
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Initialize .env
shell: bash
run: |
echo "" > .env
echo "FLICKR_API_KEY=${{ secrets.FLICKR_API_KEY }}" >> .env
echo "FLICKR_CONSUMER_SECRET=${{ secrets.FLICKR_CONSUMER_SECRET }}" >> .env
echo "FLICKR_OAUTH_TOKEN=${{ secrets.FLICKR_OAUTH_TOKEN }}" >> .env
echo "FLICKR_OAUTH_TOKEN_SECRET=${{ secrets.FLICKR_OAUTH_TOKEN_SECRET }}" >> .env
echo "FLICKR_USER_NSID=${{ vars.FLICKR_USER_NSID }}" >> .env
echo "FLICKR_USER_NAME=${{ vars.FLICKR_USER_NAME }}" >> .env
- name: Run Unit Tests
run: pnpm test -- --run
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: moontai0724/flickr-sdk
files: ./coverage/cobertura-coverage.xml
verbose: true
build-and-publish:
needs: test-and-upload-coverage
name: Build and Publish Package
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Publish Package
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: git add -f docs && npx semantic-release
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs
deploy-docs:
needs: build-and-publish
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4