Skip to content

Image version

Image version #92

Workflow file for this run

name: "ethereum-writer-deployer"
on:
push:
branches:
- '**'
pull_request:
types: [opened, synchronize]
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
release-to-staging:
# if: github.event_name == 'pull_request' && github.base_ref == 'master'
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
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: Print current and next version
# run: |
# echo "Current version: ${{ steps.get_semver.outputs.current_version }}"
# echo "Next version: ${{ steps.get_semver.outputs.next_version }}"
- name: Generate image version
run: |
COMMIT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
IMAGE_VERSION="${{ steps.get_semver.outputs.next_version }}-$COMMIT_HASH"
echo "image_version=$IMAGE_VERSION" >> $GITHUB_ENV
echo $IMAGE_VERSION > .version
- 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: 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:${{ env.image_version }} --push .
# release-to-staging:
# if: github.event_name == 'pull_request' && github.head_ref == 'main'
# needs: build-and-test
# 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: setup-docker
# uses: docker-practice/actions-setup-docker@master
# - name: Download build artifact
# uses: actions/download-artifact@v3
# with:
# name: build
# path: ./dist
# - name: Generate version
# run: ./create-version-file.sh
# - 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 .