minor: Simplify images, upload multi-arch images, pipeline updates #107
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "ethereum-writer-deployer" | |
on: | |
pull_request: | |
branches: | |
- master | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- edited | |
- labeled | |
release: | |
types: [ published ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Print tooling versions | |
run: | | |
node --version | |
npm --version | |
docker --version | |
python --version | |
- name: Run npm ci | |
run: npm ci | |
- run: npm run build | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: ./dist | |
test: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Download build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: ./dist | |
- run: npm install --no-save tap-xunit | |
- run: mkdir -p _out/unit _out/e2e | |
- run: npm test -- --timeout=1m | |
create-version-file: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Determine next version | |
id: getVersion | |
uses: Luke-Rogerson/pr-bump-version@v1 | |
- name: Write version to file | |
run: | | |
echo "Outputted version is ${{ steps.getVersion.outputs.version }}" | |
echo ${{ steps.getVersion.outputs.version }} > .version | |
- name: Upload .version file as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: version | |
path: .version | |
release-to-staging: | |
needs: | |
- build | |
- test | |
- create-version-file | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Setup Docker | |
uses: docker-practice/actions-setup-docker@master | |
- name: Download build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: ./dist | |
- name: Download version artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: version | |
path: ./ | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_STAGING_LOGIN }} | |
password: ${{ secrets.DOCKER_HUB_STAGING_PASSWORD }} | |
- name: Build and push image | |
run: | | |
echo "Tagging image with $(cat .version)" | |
docker buildx build --platform linux/amd64,linux/arm64 -t orbsnetworkstaging/ethereum-writer:$(cat .version) --push . | |
release-to-staging-immediate: | |
if: github.event_name == 'pull_request' && github.event.label.name == 'immediate' | |
needs: | |
- build | |
- test | |
- create-version-file | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Setup Docker | |
uses: docker-practice/actions-setup-docker@master | |
- name: Download build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: ./dist | |
- name: Download version artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: version | |
path: ./ | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_STAGING_LOGIN }} | |
password: ${{ secrets.DOCKER_HUB_STAGING_PASSWORD }} | |
- name: Build and push image | |
run: | | |
IMMEDIATE_VERSION=$(awk -F'-' '{print $1"-immediate"}' .version) | |
echo "Tagging image with $IMMEDIATE_VERSION" | |
docker buildx build --platform linux/amd64,linux/arm64 -t orbsnetworkstaging/ethereum-writer:$IMMEDIATE_VERSION --push . |