diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..5d9c7a9 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,45 @@ +name: Deploy to Netlify + +on: + push: + branches: ['main'] + workflow_dispatch: + inputs: + deploy-msg: + description: 'Deploy to Production' + required: true + +jobs: + deploy: + name: Build and Deploy to Netlify + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.10.0 + with: + access_token: ${{ github.token }} + + - name: Checkout repository + uses: actions/checkout@v3.2.0 + + - name: Install modules + run: npm ci + + - name: Decode .env file + run: echo "${{ secrets.ENV_FILE_CONTENT }}" | base64 -d > .env + + - name: Build + run: npm run build + + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v2.0 + with: + publish-dir: './build' + deploy-message: 'Deploy from GitHub Actions: ${{ github.event.inputs.deploy-msg }}' + production-deploy: true + github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} + enable-commit-comment: false + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + timeout-minutes: 1 diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml new file mode 100644 index 0000000..0cd7e31 --- /dev/null +++ b/.github/workflows/deploy_preview.yml @@ -0,0 +1,37 @@ +name: Deploy Preview to Netlify + +on: pull_request + +jobs: + deploy-preview: + name: Build and Deploy preview on Netlify + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.10.0 + with: + access_token: ${{ github.token }} + + - name: Checkout repository + uses: actions/checkout@v3.2.0 + + - name: Install modules + run: npm ci + + - name: Decode .env file + run: echo "${{ secrets.ENV_FILE_CONTENT }}" | base64 -d > .env + + - name: Build + run: npm run build + + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v2.0 + with: + publish-dir: './build' + deploy-message: '#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}' + github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} + enable-commit-comment: false + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + timeout-minutes: 3 diff --git a/.gitignore b/.gitignore index 2f48179..44b89e2 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ npm-debug.log* # editors .vscode + +# Local Netlify folder +.netlify diff --git a/env.example b/env.example index f2c3eea..64d4bc2 100644 --- a/env.example +++ b/env.example @@ -1 +1,2 @@ REACT_APP_DEFAULT_LANGUAGE=en +REACT_APP_DUMMY_ENV=example diff --git a/src/screens/Home/index.tsx b/src/screens/Home/index.tsx index a936926..3b622f7 100644 --- a/src/screens/Home/index.tsx +++ b/src/screens/Home/index.tsx @@ -6,6 +6,8 @@ const HomeScreen = (): JSX.Element => { return (
+ {/* TODO: This is the test line for .env file. Will remove it later. */} +
{process.env.REACT_APP_DUMMY_ENV}
logo Learn React