This repository has been archived by the owner on Oct 27, 2021. It is now read-only.
generated from actions/container-action
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
entrypoint.sh
executable file
·53 lines (46 loc) · 1.55 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -e
REPO_FULLNAME=$(jq -r ".repository.full_name" "$GITHUB_EVENT_PATH")
echo "## Initializing git repo..."
git init
echo "### Adding git remote..."
git remote add origin https://x-access-token:[email protected]/$REPO_FULLNAME.git
echo "### Getting branch"
BRANCH=${GITHUB_REF#*refs/heads/}
echo "### git fetch $BRANCH ..."
git fetch origin $BRANCH
echo "### Branch: $BRANCH (ref: $GITHUB_REF )"
git checkout $BRANCH
echo "## Login into git..."
git config --global user.email "[email protected]"
git config --global user.name "Node Code Formatter"
echo "## Ignore workflow files (we may not touch them)"
git update-index --assume-unchanged .github/workflows/*
echo "## Your environment is not ready yet. Installing modules..."
if [ -f yarn.lock ]; then
echo "## Detected yarn as package manager"
yarn --non-interactive --silent --ignore-scripts --ignore-engines --production=false
yarn config set ignore-engines true
echo "## Installing dependencies..."
yarn install
echo "## Linting code..."
yarn run lint
else
echo "## Detected NPM as package manager"
echo "## Setting environment variables..."
NODE_ENV=development
echo "## Installing dependencies..."
npm ci
echo "## Formatting code..."
npm run format --if-present
echo "## Linting code..."
npm run lint --if-present
fi
echo "## Deleting node_modules..."
rm -rf node_modules/
echo "## Staging changes..."
git add .
echo "## Commiting files..."
git commit -m "Formatted code" || true
echo "## Pushing to $BRANCH"
git push -u origin $BRANCH