Skip to content

Commit

Permalink
Merge pull request #225 from Axway/APIGOV-27565
Browse files Browse the repository at this point in the history
APIGOV-27565 - refactor workflows and actions
  • Loading branch information
dfeldick authored May 13, 2024
2 parents e1c0766 + 6e73d2f commit fa49266
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 277 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
name: Build MuleSoft Agents
name: Build agents
on:
push:
branches: [main, "APIGOV-*"]
branches: [main, "*"]

jobs:
test:
env:
GOFLAGS: "-mod=mod"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
- name: Test
working-directory: .
run: |
make test
testAgents:
uses: ./.github/workflows/run-tests.yml

build:
buildAgents:
needs: testAgents
env:
GOFLAGS: "-mod=mod"
GOWORK: "off"
VERSION: ${{ github.ref_name }}
COMMIT_ID: ${{ github.sha }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Build discovery agent
working-directory: .
run: |
make build-discovery
- name: Build traceability agent
working-directory: .
run: |
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/build-discovery-agent-docker.yml

This file was deleted.

118 changes: 118 additions & 0 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build docker images
on:
push:
tags:
- "*"

jobs:
testAgents:
uses: ./.github/workflows/run-tests.yml

buildDiscoveryAgentDocker:
needs: testAgents
env:
GOFLAGS: "-mod=mod"
IMAGE_NAME: mulesoft_discovery_agent
ORG_NAME: Axway
VERSION: ${{ github.ref_name }}
COMMIT_ID: ${{ github.sha }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set outputs
id: vars
run: |
echo "date=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
echo "tag=${{github.ref_name }}" >> $GITHUB_OUTPUT
echo "sdkversion=$(grep github.com/Axway/agent-sdk go.mod | awk '{print $2}')" >> $GITHUB_OUTPUT
echo "commit=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=false
images: ghcr.io/${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: build/discovery.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
time=${{ steps.vars.outputs.date }}
CGO_ENABLED=0
version=${{ steps.vars.outputs.tag }}
sdk_version=${{ steps.vars.outputs.sdkversion }}
commit_id=${{ steps.vars.outputs.commit }}
buildTraceabilityAgentDocker:
needs: testAgents
env:
GOFLAGS: "-mod=mod"
IMAGE_NAME: mulesoft_traceability_agent
ORG_NAME: Axway
VERSION: ${{ github.ref_name }}
COMMIT_ID: ${{ github.sha }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set outputs
id: vars
run: |
echo "date=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
echo "tag=${{github.ref_name }}" >> $GITHUB_OUTPUT
echo "sdkversion=$(grep github.com/Axway/agent-sdk go.mod | awk '{print $2}')" >> $GITHUB_OUTPUT
echo "commit=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=false
images: ghcr.io/${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: build/traceability.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
time=${{ steps.vars.outputs.date }}
CGO_ENABLED=0
version=${{ steps.vars.outputs.tag }}
sdk_version=${{ steps.vars.outputs.sdkversion }}
commit_id=${{ steps.vars.outputs.commit }}
notifyTeamsChannel:
runs-on: ubuntu-latest
needs: [buildDiscoveryAgentDocker, buildTraceabilityAgentDocker]
steps:
- uses: actions/checkout@v4
- name: Notify Teams channel
env:
TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }}
TAG: ${{ github.ref_name }}
run: ./release.sh
37 changes: 0 additions & 37 deletions .github/workflows/build-traceability-agent-docker.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/fully-automated-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- name: Get latest SDK version
run: |
export LATEST_REMOTE_TAG_CMD="git ls-remote --tags --refs --sort='version:refname' REMOTE_REPO | grep -Eo 'v?[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,3}$' | tail -1"
export LATEST_REMOTE_TAG_CMD="git ls-remote --tags --refs --sort='version:refname' REMOTE_REPO | grep -Eo 'v?[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}$' | tail -1"
REMOTE_REPO_PATH="https://github.com/Axway/agent-sdk"
CMD=${LATEST_REMOTE_TAG_CMD/"REMOTE_REPO"/${REMOTE_REPO_PATH}}
export SDK_VERSION=$(eval $CMD)
Expand All @@ -42,7 +42,7 @@ jobs:
title: 'APIGOV-UpdateSDK - Update to SDK ${{ env.SDK_VERSION }}'
delete-branch: true
reviewers: dfeldick

- name: Enable Pull Request Automerge
run: gh pr merge APIGOV-UpdateSDK --admin --merge --subject "Merge branch APIGOV-UpdateSDK"
env:
Expand Down
62 changes: 0 additions & 62 deletions .github/workflows/release.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This action is shared by workflows that want to run the unit tests
name: Test the agents

on:
workflow_call

jobs:
test:
env:
GOFLAGS: "-mod=mod"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
- name: Test
working-directory: .
run: |
echo "no tests"
# make test
Loading

0 comments on commit fa49266

Please sign in to comment.