Skip to content

Commit f15ec61

Browse files
feat: Added Payments-release (#65)
* feat: Added payments-flow-release * fix: github token value * payments snapshot updated parameters * minor fix * updated readme
1 parent bc6ec7d commit f15ec61

File tree

4 files changed

+162
-11
lines changed

4 files changed

+162
-11
lines changed

payments-flow-docker-snapshot/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and if runned manually, create a fake tag called `develop-snapshot`
1010
## how to use
1111

1212
```yaml
13-
name: payments Snapshot docker build and push
13+
name: 📦 Payments Snapshot docker
1414

1515
on:
1616
push:
@@ -37,6 +37,7 @@ jobs:
3737
ref: ${{ env.CURRENT_BRANCH }}
3838

3939
- name: 📦 Run Snapshot Docker Build/Push & Trigger
40+
# https://github.com/pagopa/github-actions-template/releases/tag/v1.16.0
4041
uses: pagopa/github-actions-template/payments-flow-docker-snapshot@main
4142
with:
4243
current_branch: ${{ github.ref_name }}
@@ -45,4 +46,9 @@ jobs:
4546
azure_devops_project_url: 'https://dev.azure.com/pagopaspa/devopslab-projects'
4647
azure_devops_pipeline_name: 'devopslab-diego-deploy.deploy'
4748
azure_devops_pat: ${{ secrets.AZUREDEVOPS_PAT }}
49+
azure_template_parameters: |
50+
{
51+
"APPS": "[one-color]",
52+
"POSTMAN_BRANCH": "${{ github.ref_name }}"
53+
}
4854
```

payments-flow-docker-snapshot/action.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ inputs:
2121
azure_devops_pat:
2222
required: false
2323
default: ''
24+
azure_template_parameters:
25+
required: false
2426

2527
runs:
2628
using: "composite"
2729
steps:
28-
- name: Log in to the Github Container registry
30+
- name: 🛃 Log in to the Github Container registry
2931
# https://github.com/docker/login-action/releases/tag/v3.3.0
3032
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
3133
with:
3234
registry: ghcr.io
3335
username: ${{ github.actor }}
3436
password: ${{ github.token }}
3537

36-
- name: Set Docker tags
38+
- name: 🤔 Set Docker tags
3739
id: set_docker_tags
3840
shell: bash
3941
run: |
@@ -43,7 +45,7 @@ runs:
4345
echo "DOCKER_TAGS=ghcr.io/${{ github.repository }}:snapshot,ghcr.io/${{ github.repository }}:snapshot-${{ inputs.current_branch }}" >> $GITHUB_OUTPUT
4446
fi
4547
46-
- name: Build and push Docker image
48+
- name: 🚀 Build and push Docker image
4749
# https://github.com/docker/build-push-action/releases/tag/v6.9.0
4850
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
4951
with:
@@ -52,7 +54,10 @@ runs:
5254
tags: ${{ steps.set_docker_tags.outputs.DOCKER_TAGS }}
5355
labels: ${{ inputs.docker_labels }}
5456

55-
- name: Check azure_devops_pat
57+
#
58+
# AZDO
59+
#
60+
- name: 🤔 Check azure_devops_pat
5661
if: ${{ inputs.enable_azure_devops_step == 'true' }}
5762
shell: bash
5863
run: |
@@ -63,16 +68,12 @@ runs:
6368
6469
echo "🔨 Start launch trigger with Azure Devops"
6570
66-
- name: Trigger Azure DevOps pipeline
71+
- name: 🚂 Trigger Azure DevOps pipeline
6772
if: ${{ inputs.enable_azure_devops_step == 'true' }}
6873
uses: jacopocarlini/azure-pipelines@v1.3
6974
with:
7075
azure-devops-project-url: ${{ inputs.azure_devops_project_url }}
7176
azure-pipeline-name: ${{ inputs.azure_devops_pipeline_name }}
7277
azure-devops-token: ${{ inputs.azure_devops_pat }}
73-
azure-template-parameters: |
74-
{
75-
"APPS": "${{ inputs.azure_devops_apps }}",
76-
"POSTMAN_BRANCH": "${{ inputs.current_branch }}"
77-
}
7878
azure-pipeline-variables: '{"system.debug": "true"}'
79+
azure-template-parameters: ${{ inputs.azure_template_parameters }}

payments-flow-release/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# payments-flow-release
2+
3+
Allows to make a release and build docker image with the follow tags:
4+
5+
- develop-vX.Y.Z
6+
- uat-vX.Y.Z
7+
- vX.Y.Z
8+
9+
## how to use
10+
11+
```yaml
12+
name: 🚀 Payments release
13+
14+
on:
15+
push:
16+
branches:
17+
- develop
18+
- uat
19+
- main
20+
paths-ignore:
21+
- 'CODEOWNERS'
22+
- '**.md'
23+
- '.**'
24+
workflow_dispatch:
25+
26+
jobs:
27+
payments-flow-release:
28+
runs-on: ubuntu-22.04
29+
environment: dev
30+
steps:
31+
- name: 🔖 Checkout code
32+
# https://github.com/actions/checkout/releases/tag/v4.2.1
33+
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
34+
with:
35+
ref: ${{ github.ref_name }}
36+
37+
- name: 🚀 release + docker + azdo
38+
# https://github.com/pagopa/github-actions-template/releases/tag/v1.16.0
39+
uses: pagopa/github-actions-template/payments-flow-release@payments-release
40+
with:
41+
current_branch: ${{ github.ref_name }}
42+
enable_azure_devops_step: 'true'
43+
azure_devops_project_url: 'https://dev.azure.com/pagopaspa/devopslab-projects'
44+
azure_devops_pipeline_name: 'devopslab-diego-deploy.deploy'
45+
azure_devops_pat: ${{ secrets.AZUREDEVOPS_PAT }}
46+
azure_template_parameters: |
47+
{
48+
"APPS": "[one-color]",
49+
"POSTMAN_BRANCH": "${{ github.ref_name }}"
50+
}
51+
```

payments-flow-release/action.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Payments release
2+
description: Payments release
3+
4+
inputs:
5+
current_branch:
6+
required: true
7+
docker_labels:
8+
required: false
9+
default: |
10+
maintainer=https://pagopa.it
11+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
12+
enable_azure_devops_step:
13+
required: false
14+
default: false
15+
azure_devops_project_url:
16+
required: false
17+
azure_devops_pipeline_name:
18+
required: false
19+
azure_devops_pat:
20+
required: false
21+
azure_template_parameters:
22+
required: false
23+
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: 🔨 Set release tag format
28+
id: set-tag-format
29+
shell: bash
30+
run: |
31+
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
32+
echo "TAG_FORMAT=develop-v\${version}" >> $GITHUB_OUTPUT
33+
elif [[ "${{ github.ref }}" == "refs/heads/uat" ]]; then
34+
echo "TAG_FORMAT=uat-v\${version}" >> $GITHUB_OUTPUT
35+
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
36+
echo "TAG_FORMAT=v\${version}" >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: 🚀 Release
40+
id: release
41+
uses: pagopa/eng-github-actions-iac-template/global/release-action@main
42+
with:
43+
github_token: ${{ github.token }}
44+
tag_format: ${{ steps.set-tag-format.outputs.TAG_FORMAT }}
45+
branches: ${{ github.ref_name }}
46+
47+
#
48+
# Docker
49+
#
50+
- name: 🔨 Set Docker tags
51+
id: set_docker_tags
52+
if: steps.release.outputs.new_release_published == 'true'
53+
shell: bash
54+
run: |
55+
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
56+
echo "DOCKER_TAGS=ghcr.io/${{ github.repository }}:develop-${{ steps.release.outputs.new_release_version }},ghcr.io/${{ github.repository }}:develop-latest,ghcr.io/${{ github.repository }}:latest" >> $GITHUB_OUTPUT
57+
elif [[ "${{ github.ref }}" == "refs/heads/uat" ]]; then
58+
echo "DOCKER_TAGS=ghcr.io/${{ github.repository }}:uat-${{ steps.release.outputs.new_release_version }},ghcr.io/${{ github.repository }}:uat-latest" >> $GITHUB_OUTPUT
59+
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
60+
echo "DOCKER_TAGS=ghcr.io/${{ github.repository }}:${{ steps.release.outputs.new_release_version }}" >> $GITHUB_OUTPUT
61+
fi
62+
63+
- name: 🛃 Log in to the Github Container registry
64+
id: docker_login
65+
if: steps.release.outputs.new_release_published == 'true'
66+
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 #v3.2.0
67+
with:
68+
registry: ghcr.io
69+
username: ${{ github.actor }}
70+
password: ${{ github.token }}
71+
72+
- name: 📦 Build and push Docker image with release version
73+
id: docker_build_push
74+
if: steps.release.outputs.new_release_published == 'true'
75+
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c #v6.3.0
76+
with:
77+
context: .
78+
push: true
79+
tags: ${{ steps.set_docker_tags.outputs.DOCKER_TAGS }}
80+
labels: ${{ inputs.docker_labels }}
81+
82+
#
83+
# AZDO
84+
#
85+
- name: 🚂 Trigger Azure DevOps pipeline
86+
if: inputs.enable_azure_devops_step == 'true' && steps.release.outputs.new_release_published == 'true'
87+
uses: jacopocarlini/azure-pipelines@v1.3
88+
with:
89+
azure-devops-project-url: ${{ inputs.azure_devops_project_url }}
90+
azure-pipeline-name: ${{ inputs.azure_devops_pipeline_name }}
91+
azure-devops-token: ${{ inputs.azure_devops_pat }}
92+
azure-pipeline-variables: '{"system.debug": "true"}'
93+
azure-template-parameters: ${{ inputs.azure_template_parameters }}

0 commit comments

Comments
 (0)