Skip to content

Commit

Permalink
adds initial package and release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
chaduhduh committed Aug 15, 2024
1 parent de68788 commit e0ab36f
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ STAGING_ROOT=/net/dl2/vospace/tmp
VOS_IDENTIFIER=ivo://datalab.noirlab/vospace
ROOT_NODE_IDENTIFIER=vos://datalab.noirlab!vospace
CAPS_IDENTIFIER=ivo://datalab.noirlab/vospace/capabilities
LOG_FILE=/usr/local/tomcat/logs/vospace.log
DEBUG=false
61 changes: 61 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Package (pre-release)

env:
GITHUB_SHA: ${{ github.sha }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/vospace

on:
push:

jobs:
package-docker:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- name: Init - register short hash
run: echo SHA_SHORT="${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Init - register image tag
run: echo IMAGE_TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHA_SHORT }}" >> $GITHUB_ENV

- name: Build - build local ANT image
run: docker build -f Dockerfile.ApacheAnt -t apache-ant .

- name: Build - create VOSpace Java build with ANT
run: docker run --rm -v ./java:/app apache-ant dist

- name: Package - build VOSpace image
run: docker build --file Dockerfile --tag ${{ env.IMAGE_TAG }} .

- name: Test - Start VOSpace container
run: |
docker run -d \
--env-file .env.example \
--name vospace-example \
--port 3001:8080/tcp \
${{ env.IMAGE_TAG }}
- name: Test - perform health checks
run: |
curl \
--fail \
--connect-timeout 10 \
--retry 3 \
--retry-delay 5 \
--retry-max-time 40 \
--retry-all-errors \
-o /dev/null \
http://localhost:3001/vospace-2.0/vospace/
- name: Publish - Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish - Push the new tag
run: docker push ${{ env.IMAGE_TAG }}
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Version Release
on:
release:
types: [released]

env:
GITHUB_SHA: ${{ github.sha }}

jobs:

release-docker:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/vospace
RELEASE_TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4

- name: generate short hash
run: echo BUILD_SHA="${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull the existing image for this commit
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BUILD_SHA }}

- name: Create the new tag
run: docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BUILD_SHA }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RELEASE_TAG }}

- name: Push the new tag
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RELEASE_TAG }}

- name: Create the latest tag
run: docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BUILD_SHA }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

- name: Push the latest tag
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

- name: Cleanup left over docker data
run: rm -rf ~/.docker

0 comments on commit e0ab36f

Please sign in to comment.