Skip to content

Commit

Permalink
APIGOV-27565 - refactor workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
dfeldickgit committed May 10, 2024
1 parent f942351 commit 04e0ae4
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 7 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build-agents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build agents
on:
push:
branches: [main, "*"]

jobs:
testDiscoveryAgent:
uses: ./.github/workflows/run-da-tests.yml

testTraceabilityAgent:
uses: ./.github/workflows/run-ta-tests.yml

buildDiscoveryAgent:
needs: testDiscoveryAgent
env:
GOFLAGS: "-mod=mod"
GOWORK: "off"
defaults:
run:
working-directory: ${{ env.GOPATH }}/discovery
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: discovery
run: |
git fetch --all --tags --quiet
git branch --show-current > commit_id
git tag -l --sort='version:refname' | grep -Eo '[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,3}$' | tail -1 > version
make build
- uses: actions/upload-artifact@v4
with:
name: apigee_discovery_agent
path: discovery/bin/apigee_discovery_agent

buildTraceabilityAgent:
needs: testTraceabilityAgent
env:
GOFLAGS: "-mod=mod"
GOWORK: "off"
defaults:
run:
working-directory: ${{ env.GOPATH }}/traceability
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 traceability agent
working-directory: traceability
run: |
git fetch --all --tags --quiet
git branch --show-current > commit_id
git tag -l --sort='version:refname' | grep -Eo '[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,3}$' | tail -1 > version
make build
- uses: actions/upload-artifact@v4
with:
name: apigee_traceability_agent
path: traceability/bin/apigee_traceability_agent

- uses: actions/upload-artifact@v4
with:
name: apigee_traceability_agent.yml
path: traceability/apigee_traceability_agent.yml
2 changes: 1 addition & 1 deletion .github/workflows/build-apigee-discovery-agent-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Discovery Agent Docker
on:
push:
tags:
- "*"
- "*xxx"

jobs:
buildDiscoveryAgentDocker:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build-apigee-discovery-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build Apigee Discovery Agent

on:
push:
branches: [main, "*"]
# branches: [main, "*"]
tags:
- "*"
- "*xxx"

jobs:
testDiscoveryAgent:
Expand Down Expand Up @@ -56,4 +56,3 @@ jobs:
with:
name: apigee_discovery_agent
path: discovery/bin/apigee_discovery_agent

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Traceability Agent Docker
on:
push:
tags:
- "*"
- "*xxx"

jobs:
buildtraceabilityAgentDocker:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-apigee-traceability-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build Apigee Traceability Agent

on:
push:
branches: [main, "*"]
# branches: [main, "*"]
tags:
- "*"
- "*xxx"

jobs:
testTraceabilityAgent:
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Discovery Agent Docker

on:
push:
tags:
- "*"

jobs:
testDiscoveryAgent:
uses: ./.github/workflows/run-da-tests.yml

testTraceabilityAgent:
uses: ./.github/workflows/run-ta-tests.yml

buildDiscoveryAgentDocker:
needs: testDiscoveryAgent
env:
GOFLAGS: "-mod=mod"
GOWORK: "off"
IMAGE_NAME: apigee_discovery_agent
ORG_NAME: Axway
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create commit_id & version files
working-directory: discovery
run: |
git branch --show-current > commit_id
echo "${{ github.ref_name }}" > version
- 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: discovery/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


buildtraceabilityAgentDocker:
needs: testTraceabilityAgent
env:
GOFLAGS: "-mod=mod"
GOWORK: "off"
IMAGE_NAME: apigee_traceability_agent
ORG_NAME: Axway
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create commit_id & version files
working-directory: traceability
run: |
git branch --show-current > commit_id
echo "${{ github.ref_name }}" > version
- 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: traceability/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
26 changes: 26 additions & 0 deletions .github/workflows/run-da-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This action is shared by workflows that want to run the unit tests
name: Test the agents

on:
workflow_call

jobs:
testDiscoveryAgent:
env:
GOFLAGS: "-mod=mod"
GOWORK: "off"
defaults:
run:
working-directory: ${{ env.GOPATH }}/discovery
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 discovery agent
working-directory: discovery
run: make test
26 changes: 26 additions & 0 deletions .github/workflows/run-ta-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This action is shared by workflows that want to run the unit tests
name: Test the agents

on:
workflow_call

jobs:
testTraceabilityAgent:
env:
GOFLAGS: "-mod=mod"
GOWORK: "off"
defaults:
run:
working-directory: ${{ env.GOPATH }}/traceability
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 traceability agent
working-directory: traceability
run: make test

0 comments on commit 04e0ae4

Please sign in to comment.