diff --git a/.github/workflows/on-main.yaml b/.github/workflows/on-main.yaml new file mode 100644 index 0000000..5747083 --- /dev/null +++ b/.github/workflows/on-main.yaml @@ -0,0 +1,38 @@ +name: Test and build + +on: + push: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x, 15.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run test:ganache & + - run: npm run test:start & + - run: sleep 10 && npm test + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get the version + id: vars + run: echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) + - name: Run docker build + run: docker build -t vulcanize/testing-framework -f Dockerfile . + - name: Tag docker image + run: docker tag vulcanize/testing-framework docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} + - name: Docker Login + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin + - name: Docker Push + run: docker push docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml new file mode 100644 index 0000000..31ffefe --- /dev/null +++ b/.github/workflows/on-pr.yaml @@ -0,0 +1,32 @@ +name: Test and build + +on: + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x, 15.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run test:ganache & + - run: npm run test:start & + - run: sleep 10 && npm test + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get the version + id: vars + run: echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) + - name: Run docker build + run: docker build -t vulcanize/testing-framework -f Dockerfile . diff --git a/.github/workflows/on-release.yaml b/.github/workflows/on-release.yaml new file mode 100644 index 0000000..6560ee4 --- /dev/null +++ b/.github/workflows/on-release.yaml @@ -0,0 +1,27 @@ +name: Publish docker image + +on: + release: + types: [ published ] + +jobs: + + release: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Get the version + id: vars + run: | + echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) + echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) + - name: Docker Login to Github Registry + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin + - name: Docker Pull + run: docker pull docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} + - name: Docker Login to Docker Registry + run: echo ${{ secrets.VULCANIZEJENKINS_PAT }} | docker login -u vulcanizejenkins --password-stdin + - name: Tag docker image + run: docker tag docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} vulcanize/testing-framework:${{steps.vars.outputs.tag}} + - name: Docker Push to Docker Hub + run: docker push vulcanize/testing-framework:${{steps.vars.outputs.tag}} \ No newline at end of file diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml deleted file mode 100644 index 65751d1..0000000 --- a/.github/workflows/workflow.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: integration tests - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - release: - types: [ published ] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x, 15.x] - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run test:ganache & - - run: npm run test:start & - - run: sleep 10 && npm test - build: - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Get the version - id: vars - run: echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) - - name: Run docker build - run: docker build -t vulcanize/testing-framework -f Dockerfile . - - name: Tag docker image - run: docker tag vulcanize/testing-framework docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} - - name: Docker Login - if: ${{ github.repository == 'vulcanize/testing-framework' }} - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin - - name: Docker Push - if: ${{ github.repository == 'vulcanize/testing-framework' }} - run: docker push docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} - release: - if: ${{ github.repository == 'vulcanize/testing-framework' && github.event_name == 'release' && github.ref == 'refs/heads/published' }} - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Get the version - id: vars - run: | - echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) - echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) - - name: Docker Login to Github Registry - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin - - name: Docker Pull - run: docker pull docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} - - name: Docker Login to Docker Registry - run: echo ${{ secrets.VULCANIZEJENKINS_PAT }} | docker login -u vulcanizejenkins --password-stdin - - name: Tag docker image - run: docker tag docker.pkg.github.com/vulcanize/testing-framework/testing-framework:${{steps.vars.outputs.sha}} vulcanize/testing-framework:${{steps.vars.outputs.tag}} - - name: Docker Push to Docker Hub - run: docker push vulcanize/testing-framework:${{steps.vars.outputs.tag}} \ No newline at end of file