Skip to content

minor: Simplify images, upload multi-arch images, pipeline updates #102

minor: Simplify images, upload multi-arch images, pipeline updates

minor: Simplify images, upload multi-arch images, pipeline updates #102

Workflow file for this run

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
determine-version:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract PR title
id: extract_title
run: |
TITLE="${{ github.event.pull_request.title }}"
echo "PR title: $TITLE"
echo "pr_title=$TITLE" >> $GITHUB_ENV
- name: Determine Version Increment
id: version_increment
run: |
TITLE=$(echo "${{ env.pr_title }}" | awk '{print tolower($0)}')
echo "Lowercased PR title: $TITLE"
if [[ $TITLE == patch* ]]; then
increment="patch"
elif [[ $TITLE == minor* ]]; then
increment="minor"
elif [[ $TITLE == major* ]]; then
increment="major"
else
echo "Invalid PR title. Exiting."
exit 1
fi
echo "increment=$increment" >> $GITHUB_ENV
- uses: rickstaa/action-get-semver@v1
id: get_semver
with:
bump_level: "${{ env.increment }}"
- name: Generate image version
run: |
COMMIT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
IMAGE_VERSION="${{ steps.get_semver.outputs.next_version }}-$COMMIT_HASH"
if [[ ${{ github.event_name }} == 'release' ]]; then
echo "Release event detected. Using version from tag."
IMAGE_VERSION="${{ steps.get_semver.outputs.next_version }}"
fi
echo "Generated image version: $IMAGE_VERSION"
echo $IMAGE_VERSION > .version
- name: Upload .version as artifact
uses: actions/upload-artifact@v3
with:
name: version
path: .version
release-to-staging:
needs:
- build
- test
- determine-version
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: docker buildx build --platform linux/amd64,linux/arm64 -t orbsnetworkstaging/ethereum-writer:$(cat .version) --push .
run: 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
- determine-version
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)
docker buildx build --platform linux/amd64,linux/arm64 -t orbsnetworkstaging/ethereum-writer:$IMMEDIATE_VERSION --push .