Skip to content

Commit 0a3e4e0

Browse files
andre-lxportellaa
andauthored
chore(actions): fix released action (#18)
Co-authored-by: Luís Portela Afonso <luis.portela@ydata.ai>
1 parent 4a5ff92 commit 0a3e4e0

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

.github/workflows/prereleased.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ jobs:
6565
- name: Configure AWS credentials
6666
uses: aws-actions/configure-aws-credentials@v1
6767
with:
68-
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESSKEYID }}
69-
aws-secret-access-key: ${{ secrets.AWS_ECR_SECRETACCESSKEY }}
68+
role-to-assume: ${{ secrets.AWS_ECR_ROLE_ARN }}
7069
aws-region: ${{ secrets.AWS_ECR_REGION }}
7170

7271
- name: Login to Amazon ECR

.github/workflows/released.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,25 @@ jobs:
3838

3939
outputs:
4040
build_number: ${{ steps.short_sha.outputs.value }}
41-
version: ${{ steps.version.outputs.value }}
41+
new_version: ${{ steps.new_version.outputs.value }}
42+
old_version: ${{ steps.old_version.outputs.value }}
4243

4344
steps:
4445
- name: Version
45-
id: version
46+
id: new_version
4647
run: echo ::set-output name=value::${GITHUB_REF#refs/*/}
4748

4849
- uses: actions/checkout@v3
50+
with:
51+
fetch-depth: 0
4952

5053
- name: Git Short sha
5154
id: short_sha
52-
run: echo "::set-output name=value::$(git rev-parse --short HEAD)"
55+
run: echo ::set-output name=value::$(git rev-parse --short HEAD)
56+
57+
- name: Extract original version
58+
id: old_version
59+
run: echo ::set-output name=value::$(git tag | grep ${{ steps.short_sha.outputs.value }} | sed -r 's|([0-9].[0-9].[0-9]).*|\1|g')
5360

5461

5562
docker-tag:
@@ -63,8 +70,7 @@ jobs:
6370
- name: Configure AWS credentials
6471
uses: aws-actions/configure-aws-credentials@v1
6572
with:
66-
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESSKEYID }}
67-
aws-secret-access-key: ${{ secrets.AWS_ECR_SECRETACCESSKEY }}
73+
role-to-assume: ${{ secrets.AWS_ECR_ROLE_ARN }}
6874
aws-region: ${{ secrets.AWS_ECR_REGION }}
6975

7076
- name: Login to Amazon ECR
@@ -79,9 +85,9 @@ jobs:
7985

8086
- name: Docker tag and push
8187
env:
82-
SOURCE: ${{ steps.ecr.outputs.registry }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.build_number }}
83-
DESTINATION_ECR: ${{ steps.ecr.outputs.registry }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}
84-
DESTINATION_DOCKERHUB: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}
88+
SOURCE: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.old_version }}.${{ needs.prepare.outputs.build_number }}
89+
DESTINATION_ECR: ${{ steps.ecr.outputs.registry }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.new_version }}
90+
DESTINATION_DOCKERHUB: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.new_version }}
8591
run: |
8692
docker pull $SOURCE
8793
docker tag $SOURCE $DESTINATION_ECR
@@ -109,13 +115,11 @@ jobs:
109115
token: ${{ secrets.ACCESS_TOKEN }}
110116

111117
- name: Update aws-marketplace
112-
env:
113-
VERSION: ${{ needs.prepare.outputs.version }}
114-
run: echo ${{ env.VERSION }} > ${{ env.COMPONENT }}
118+
run: echo ${{ needs.prepare.outputs.new_version }} > ${{ env.COMPONENT }}
115119

116120
- name: Commit and push image update into manifests repo
117121
env:
118-
VERSION: ${{ needs.prepare.outputs.version }}
122+
VERSION: ${{ needs.prepare.outputs.new_version }}
119123
run: |
120124
git config user.email "azory@ydata.ai"
121125
git config user.name "Azory YData Bot"

0 commit comments

Comments
 (0)