Skip to content

Commit

Permalink
fix: empty commit for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipe Forattini committed Jul 18, 2022
1 parent f85d900 commit e2c750f
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 20 deletions.
8 changes: 6 additions & 2 deletions .github/actions/config-scrapper/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
outputs:
actor:
description: ""
build_args:
description: ""
build_tags:
description: ""
commiter_name:
description: ""
commiter_email:
Expand All @@ -22,8 +26,6 @@ outputs:
description: ""
deploy_tag:
description: ""
deploy_tags:
description: ""
event:
description: ""
environment:
Expand All @@ -36,6 +38,8 @@ outputs:
description: ""
language:
description: ""
registry:
description: ""

runs:
using: "node16"
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/config-scrapper/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/config-scrapper/index.js.map

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions .github/actions/pack-docker-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Static code analysis'
description: 'Greet someone'

inputs:
environment:
description: 'Environment target'
required: false
default: 'dev'
cached:
description: 'Inform the main repository language'
required: false
default: 'true'
platforms:
description: "Multi plataform container builds"
required: false
default: "linux/386,linux/amd64,linux/arm/v7,linux/arm/v8,linux/arm64,linux/ppc64le,linux/s390x"

runs:
using: "composite"

steps:
- name: Pipeline config scrapper
id: analysis
uses: filipeforattini/ff-iac-github-actions/.github/actions/config-scrapper@main

- name: Build and push
uses: docker/build-push-action@v2
if: inputs.cached == 'false'
with:
context: .
push: true
platforms: ${{ inputs.platforms }}
tags: ${{steps.analysis.outputs.build_tags}}
build-args: ${{steps.analysis.outputs.build_args}}

- name: Build and push
uses: docker/build-push-action@v2
if: inputs.cached == 'true'
with:
context: .
push: true
platforms: ${{ inputs.platforms }}
build-args: ${{steps.analysis.outputs.build_args}}
tags: ${{steps.analysis.outputs.deploy_tags}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
"commit": "npm run build && git pull && git commit --allow-empty -am \"fix: empty commit for testing\" && git push",
"build-composition": "ACTION_NAME=setup-binaries mkdir -p .github/actions/$ACTION_NAME && cp src/actions/$ACTION_NAME/action.yml .github/actions/$ACTION_NAME/action.yml",
"build-action-js": "mkdir -p .github/actions/create-releaserc-file && ncc build src/actions/$ACTION_NAME/index.js -m -q -s -o .github/actions/$ACTION_NAME && rm -f .github/actions/$ACTION_NAME/action.yml && cp src/actions/$ACTION_NAME/action.yml .github/actions/$ACTION_NAME/action.yml",
"build": "npm run action:config-scrapper && npm run action:setup-binaries && npm run action:pack-static-code-analysis && npm run action:create-releaserc-file && npm run action:semantic-release && npm run action:pack-semantic-release && npm run action:create-dockerignore && npm run action:create-dockerfile",
"build": "npm run action:config-scrapper && npm run action:setup-binaries && npm run action:pack-static-code-analysis && npm run action:create-releaserc-file && npm run action:semantic-release && npm run action:pack-semantic-release && npm run action:create-dockerignore && npm run action:create-dockerfile && npm run action:pack-docker-build",
"action:config-scrapper": "ACTION_NAME=config-scrapper npm run build-action-js",
"action:pack-static-code-analysis": "mkdir -p .github/actions/pack-static-code-analysis && cp src/actions/pack-static-code-analysis/action.yml .github/actions/pack-static-code-analysis/action.yml",
"action:create-releaserc-file": "ACTION_NAME=create-releaserc-file npm run build-action-js",
"action:semantic-release": "ACTION_NAME=semantic-release npm run build-action-js",
"action:create-dockerignore": "ACTION_NAME=create-dockerignore npm run build-action-js",
"action:create-dockerfile": "ACTION_NAME=create-dockerfile npm run build-action-js",
"action:setup-binaries": "ACTION_NAME=setup-binaries npm run build-composition",
"action:pack-semantic-release": "ACTION_NAME=pack-semantic-release npm run build-composition"
"action:pack-semantic-release": "ACTION_NAME=pack-semantic-release npm run build-composition",
"action:pack-docker-build": "ACTION_NAME=pack-docker-build npm run build-composition"
},
"repository": {
"type": "git",
Expand Down
8 changes: 6 additions & 2 deletions src/actions/config-scrapper/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
outputs:
actor:
description: ""
build_args:
description: ""
build_tags:
description: ""
commiter_name:
description: ""
commiter_email:
Expand All @@ -22,8 +26,6 @@ outputs:
description: ""
deploy_tag:
description: ""
deploy_tags:
description: ""
event:
description: ""
environment:
Expand All @@ -36,6 +38,8 @@ outputs:
description: ""
language:
description: ""
registry:
description: ""

runs:
using: "node16"
Expand Down
15 changes: 9 additions & 6 deletions src/actions/config-scrapper/src/deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ module.exports = async (analysis) => {

const commitSha = github.context.sha.substring(0,7)
const [ organization, name ] = github.context.payload.repository.full_name.split('/')
const imageFullName = [ containerRegistry, organization, name].join('/')
const registry = [ containerRegistry, organization, name].join('/')

analysis.deployment.registry = registry

if (github.context.payload.deployment) {
analysis.environment = github.context.payload.deployment.environment
analysis.outputs.environment = analysis.environment
}

let tag = `${imageFullName}:c-${commitSha}`
let tag = `${registry}:c-${commitSha}`
let tags = [
`latest`,
`c-${commitSha}`,
Expand All @@ -26,7 +28,7 @@ module.exports = async (analysis) => {
]

if (environment) {
tag = `${imageFullName}:e-${environment}-c-${commitSha}`
tag = `${registry}:e-${environment}-c-${commitSha}`
tags = tags.concat([
`e-${environment}-latest`,
`e-${environment}-r-${github.context.runNumber}`,
Expand Down Expand Up @@ -57,7 +59,7 @@ module.exports = async (analysis) => {
}
}

tags = tags.map(t => `${imageFullName}:${t}`)
tags = tags.map(t => `${registry}:${t}`)

analysis.deployment.tag = tag
analysis.deployment.tags = tags
Expand All @@ -74,7 +76,8 @@ module.exports = async (analysis) => {
analysis.deployment.build_args = args

// outputs
analysis.outputs.deploy_tag = analysis.deployment.tag
analysis.outputs.deploy_tags = analysis.deployment.tagsString
analysis.outputs.registry = analysis.deployment.registry
analysis.outputs.build_args = analysis.deployment.build_args
analysis.outputs.build_tags = analysis.deployment.tagsString
analysis.outputs.deploy_tag = analysis.deployment.tag
}
10 changes: 4 additions & 6 deletions src/actions/pack-docker-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ runs:
context: .
push: true
platforms: ${{ inputs.platforms }}
build-args: ${{steps.node_setup.outputs.docker_image_args}}
tags: ${{steps.node_setup.outputs.docker_image_tags}}, ${{steps.node_setup.outputs.docker_image_fullname}}:${{needs.Release.outputs.Version}}
labels: "organization: ${{github.repository_owner}}, repository: ${{github.repository}}, branch: ${{needs.Setup.outputs.Branch}}, commit: ${{needs.Setup.outputs.ShaHash}}, date: ${{needs.Setup.outputs.Date}}, timestamp: ${{needs.Setup.outputs.Timestamp}}"
tags: ${{steps.analysis.outputs.build_tags}}
build-args: ${{steps.analysis.outputs.build_args}}

- name: Build and push
uses: docker/build-push-action@v2
Expand All @@ -41,8 +40,7 @@ runs:
context: .
push: true
platforms: ${{ inputs.platforms }}
build-args: ${{steps.node_setup.outputs.docker_image_args}}
tags: ${{steps.node_setup.outputs.docker_image_tags}}, ${{steps.node_setup.outputs.docker_image_fullname}}:${{needs.Release.outputs.Version}}
labels: "organization: ${{github.repository_owner}}, repository: ${{github.repository}}, branch: ${{needs.Setup.outputs.Branch}}, commit: ${{needs.Setup.outputs.ShaHash}}, date: ${{needs.Setup.outputs.Date}}, timestamp: ${{needs.Setup.outputs.Timestamp}}"
build-args: ${{steps.analysis.outputs.build_args}}
tags: ${{steps.analysis.outputs.deploy_tags}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

0 comments on commit e2c750f

Please sign in to comment.