-
Notifications
You must be signed in to change notification settings - Fork 97
66 lines (66 loc) · 2.71 KB
/
main.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
name: main
on: [ push, pull_request ]
env:
GITHUB_REPOSITORY_SSH_URL: "git@github.com:${{ github.repository }}.git"
TMP_DOCKER_IMAGE: "getmeli/meli/${{ github.ref }}"
DOCKER_IMAGE: "getmeli/meli"
IS_RELEASE_BRANCH: "${{ github.ref == 'refs/heads/latest' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/beta' }}"
GIT_AUTHOR_NAME: "meli-release-bot"
GIT_COMMITTER_NAME: "meli-release-bot"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "set variables"
run: |
echo -n `echo -n "${GITHUB_REF//refs\/heads\//}" | tr -d '\n'` > HEAD_BRANCH
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: "install dependencies"
run: npm ci
- name: "create VERSION and RELEASE_CHANNEL file"
if: ${{ env.IS_RELEASE_BRANCH == 'true' }}
run: |
source ./scripts/setup-git.sh "$RELEASE_DEPLOY_KEY"
echo $GITHUB_REPOSITORY_SSH_URL
npx semantic-release -r $GITHUB_REPOSITORY_SSH_URL -d
echo "Next release version is $(cat VERSION)"
echo "Next release channel is $(cat RELEASE_CHANNEL)"
npm version --no-git-tag-version $(cat VERSION) --allow-same-version
env:
RELEASE_DEPLOY_KEY: ${{ secrets.RELEASE_DEPLOY_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: "Lint"
run: npm run lint
- name: "test"
run: npm run test
- name: "build"
run: npm run build
- name: "docker build"
run: docker build --pull -t $TMP_DOCKER_IMAGE -f ./Dockerfile .
- name: "release"
if: ${{ github.ref == 'refs/heads/latest' || github.ref == 'refs/heads/beta' }}
run: |
source ./scripts/setup-git.sh "$RELEASE_DEPLOY_KEY"
npx semantic-release -r $GITHUB_REPOSITORY_SSH_URL
env:
RELEASE_DEPLOY_KEY: ${{ secrets.RELEASE_DEPLOY_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: "publish dockerhub"
if: ${{ env.IS_RELEASE_BRANCH == 'true' }}
run: |
docker login -u $DOCKER_USER -p $DOCKER_TOKEN
IS_NEXT=${{ github.ref == 'refs/heads/next' }}
npx docker-semver-tags --sourceImage $TMP_DOCKER_IMAGE --targetImage $DOCKER_IMAGE --versionTag $(cat VERSION) --channelOnly $IS_NEXT
env:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
- name: "realign next"
if: ${{ env.IS_RELEASE_BRANCH == 'true' }}
run: |
source ./scripts/setup-git.sh "$RELEASE_DEPLOY_KEY"
./scripts/rebase-git-branch.sh "next" "$(cat HEAD_BRANCH)"
env:
RELEASE_DEPLOY_KEY: ${{ secrets.RELEASE_DEPLOY_KEY }}