Skip to content

Commit

Permalink
feat: ASG Tag lambda function (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa authored Jun 23, 2022
1 parent 1d450cd commit daaef10
Show file tree
Hide file tree
Showing 23 changed files with 818 additions and 27 deletions.
73 changes: 71 additions & 2 deletions .github/workflows/prereleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:
GHCR_USERNAME: ${{ github.repository_owner }}
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

DOCKERHUB_REGISTRY: ydata/

DOCKER_REPOSITORY: aws-asg-tags-lambda


Expand Down Expand Up @@ -47,8 +49,41 @@ jobs:
run: echo ::set-output name=value::${GITHUB_REF#refs/*/}


build:
name: Build
build-dockerhub:
name: Build and push to Docker Hub
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Login to Dockerhub Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
env:
DOCKER_IMAGE_TAG: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}
with:
push: true
tags: ${{ env.DOCKER_IMAGE_TAG }}


build-ghcr:
name: Build and push to Github Container Registry
runs-on: ubuntu-20.04

needs:
Expand Down Expand Up @@ -79,3 +114,37 @@ jobs:
with:
push: true
tags: ${{ env.DOCKER_IMAGE_TAG }}


update-manifests:
name: Update AWS Marketplace
runs-on: ubuntu-20.04

needs:
- prepare
- build-ghcr

env:
COMPONENT: ASG_TAGS_LAMBDA_VERSION

steps:
- name: Checkout AWS Marketplace repo
uses: actions/checkout@v3
with:
repository: ydataai/aws-marketplace
token: ${{ secrets.ACCESS_TOKEN }}

- name: Update aws-marketplace
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: echo ${{ env.VERSION }} > ${{ env.COMPONENT }}

- name: Commit and push image update into manifests repo
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
git config user.email "[email protected]"
git config user.name "Azory YData Bot"
git add ${{ env.COMPONENT }}
git commit -a -m "chore(bump): [CI] [DEV] bump ${{ env.COMPONENT }} to $VERSION"
git push origin master
64 changes: 62 additions & 2 deletions .github/workflows/released.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:
GHCR_USERNAME: ${{ github.repository_owner }}
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

DOCKERHUB_REGISTRY: ydata/

DOCKER_REPOSITORY: aws-asg-tags-lambda


Expand Down Expand Up @@ -54,8 +56,32 @@ jobs:
run: echo "::set-output name=value::$(git rev-parse --short HEAD)"


docker:
name: Docker Tag and Push
docker-tag-dockerhub:
name: Docker Tag and Push to Docker Hub
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- name: Login to Dockerhub Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Docker tag and push
env:
SOURCE: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.build_number }}
DESTINATION: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}
run: |
docker pull $SOURCE
docker tag $SOURCE $DESTINATION
docker push $DESTINATION
docker-tag-ghcr:
name: Docker Tag and Push to Github Container Registry
runs-on: ubuntu-20.04

needs:
Expand All @@ -77,3 +103,37 @@ jobs:
docker pull $SOURCE
docker tag $SOURCE $DESTINATION
docker push $DESTINATION
update-manifests:
name: Update AWS Marketplace
runs-on: ubuntu-20.04

needs:
- prepare
- docker-tag-ghcr

env:
COMPONENT: ASG_TAGS_LAMBDA_VERSION

steps:
- name: Checkout AWS Marketplace repo
uses: actions/checkout@v3
with:
repository: ydataai/aws-marketplace
token: ${{ secrets.ACCESS_TOKEN }}

- name: Update aws-marketplace
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: echo ${{ env.VERSION }} > ${{ env.COMPONENT }}

- name: Commit and push image update into manifests repo
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
git config user.email "[email protected]"
git config user.name "Azory YData Bot"
git add ${{ env.COMPONENT }}
git commit -a -m "chore(bump): [CI] [PROD] bump ${{ env.COMPONENT }} to $VERSION"
git push origin master
94 changes: 92 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,57 @@
{
"pins" : [
{
"identity" : "async-http-client",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "794dc9d42720af97cedd395e8cd2add9173ffd9a",
"version" : "1.11.1"
}
},
{
"identity" : "jmespath.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/adam-fowler/jmespath.swift.git",
"state" : {
"revision" : "4513d319c4aaa6c3b2ac18e1e6566a803515ad91",
"version" : "1.0.2"
}
},
{
"identity" : "soto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/soto-project/soto.git",
"state" : {
"revision" : "9c938aadbbb33d6ed54d04dd6ba494f7f12e0905",
"version" : "6.0.0"
}
},
{
"identity" : "soto-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/soto-project/soto-core.git",
"state" : {
"revision" : "8e63c0f80db61f01c346f5109863bc2be29093e7",
"version" : "6.0.0"
}
},
{
"identity" : "swift-aws-lambda-events",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ydataai/swift-aws-lambda-events.git",
"state" : {
"branch" : "main",
"revision" : "94642d229fea2459ee8400898431160d6f13ffb4"
}
},
{
"identity" : "swift-aws-lambda-runtime",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/swift-aws-lambda-runtime.git",
"state" : {
"revision" : "699ada1724459582303c15aae64fa12ca4d33809",
"version" : "0.5.2"
"branch" : "main",
"revision" : "cb340de265665e23984b1f5de3ac4d413a337804"
}
},
{
Expand All @@ -27,6 +72,15 @@
"version" : "1.4.2"
}
},
{
"identity" : "swift-metrics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "1c1408bf8fc21be93713e897d2badf500ea38419",
"version" : "2.3.1"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
Expand All @@ -35,6 +89,42 @@
"revision" : "124119f0bb12384cef35aa041d7c3a686108722d",
"version" : "2.40.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "a75e92bde3683241c15df3dd905b7a6dcac4d551",
"version" : "1.12.1"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "108ac15087ea9b79abb6f6742699cf31de0e8772",
"version" : "1.22.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "42436a25ff32c390465567f5c089a9a8ce8d7baf",
"version" : "2.20.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "2cb54f91ddafc90832c5fa247faf5798d0a7c204",
"version" : "1.13.0"
}
}
],
"version" : 2
Expand Down
33 changes: 26 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,36 @@ import PackageDescription

let package = Package(
name: "aws-asg-tags-lambda",
platforms: [
.macOS(.v12)
],
dependencies: [
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "0.5.2")
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main"),
.package(url: "https://github.com/ydataai/swift-aws-lambda-events.git", branch: "main"),
.package(url: "https://github.com/soto-project/soto.git", from: "6.0.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.11.1")
],
targets: [
.target(name: "Models"),
.target(
name: "App",
dependencies: [
.byName(name: "Models"),
.product(name: "AsyncHTTPClient", package: "async-http-client"),
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
.product(name: "SotoAutoScaling", package: "soto"),
.product(name: "SotoEKS", package: "soto")
],
swiftSettings: [ .unsafeFlags(["-cross-module-optimization"], .when(configuration: .release)) ]
),
.executableTarget(
name: "Run",
name: "CloudFormation",
dependencies: [
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime")
]),
.testTarget(
name: "LambdaTests",
dependencies: ["Run"])
.byName(name: "App"),
.byName(name: "Models"),
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events")
],
swiftSettings: [ .unsafeFlags(["-cross-module-optimization"], .when(configuration: .release)) ]
)
]
)
Loading

0 comments on commit daaef10

Please sign in to comment.