feat: build test #20
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: Release | |
on: | |
push: | |
branches: | |
- feat/workflow-tests | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
outputs: | |
new_tag_version: ${{ steps.tag_version.outputs.new_tag_version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm ci | |
- name: Dry run to get the next release version | |
id: tag_version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export NEXT_TAG_VERSION=$(npx semantic-release --dry-run | grep 'The next release version is' | sed -E 's/.* ([[:alnum:].\-]+)$/\1/') | |
echo "new_tag_version=${NEXT_TAG_VERSION}" >> $GITHUB_OUTPUT | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: npx semantic-release | |
publish-docker-images: | |
runs-on: ubuntu-latest | |
needs: release | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
strategy: | |
matrix: | |
include: | |
- context: "ch-edc" | |
directory: "clearing-house-edc" | |
dockerfile: "launchers/connector-prod/Dockerfile" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
if: ${{ matrix.context == 'ch-edc'}} | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Set version variable | |
if: ${{ needs.release.outputs.new_tag_version == 'ch-edc'}} | |
run: | | |
TAG=${{ github.ref_name }} | |
echo "VERSION=${TAG#v}" >> $GITHUB_ENV | |
- name: Build project | |
if: ${{ matrix.context == 'ch-edc'}} | |
run: | | |
cd clearing-house-edc | |
./gradlew clean build \ | |
-PdefaultVersion=${VERSION} \ | |
-Dorg.gradle.project.gitHubUserName=${{ github.actor }} \ | |
-Dorg.gradle.project.gitHubUserPassword=${{ secrets.GITHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Build Docker image | |
env: | |
DOCKER_IMAGE_TAG: ${{ needs.release.outputs.new_tag_version }} | |
run: | | |
cd ${{ matrix.directory }} | |
docker build -t ghcr.io/${{ github.repository }}/${{ matrix.context }}:$DOCKER_IMAGE_TAG -f ${{ matrix.dockerfile }} . | |
- name: Push Docker image | |
env: | |
DOCKER_IMAGE_TAG: ${{ needs.release.outputs.new_tag_version }} | |
run: docker push ghcr.io/${{ github.repository }}/${{ matrix.context }}:$DOCKER_IMAGE_TAG | |