Skip to content

Publish πŸš€

Publish πŸš€ #1317

Workflow file for this run

name: Publish πŸš€
on:
schedule:
- cron: '0 5,19 * * *'
jobs:
deployment:
name: Publish the image
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
ALPINE_VERSION: "3.20"
steps:
- name: Check out repository code
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Get latest AWS CLI version
id: latest_version
uses: tdemin/find-latest-tag@v1
with:
repo: https://github.com/aws/aws-cli.git
tag: '2\.[0-9]+\.[0-9]+'
- name: Check if tag exists already
id: check_tag
run: |
if git rev-parse ${{ steps.latest_version.outputs.tag }} >/dev/null 2>&1
then
echo "tag_exists=true" >> $GITHUB_OUTPUT
else
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
- name: Set AWS CLI version as env var
if: steps.check_tag.outputs.tag_exists == 'false'
run: echo "AWS_CLI_VERSION=${{ steps.latest_version.outputs.tag }}" >> $GITHUB_ENV
- name: Set image name as env var
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
echo "IMAGE_NAME=ghcr.io/${{ github.repository }}:${{ env.AWS_CLI_VERSION }}" >> $GITHUB_ENV
echo "IMAGE_NAME_LATEST=ghcr.io/${{ github.repository }}:latest" >> $GITHUB_ENV
- name: Set up QEMU
if: steps.check_tag.outputs.tag_exists == 'false'
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm64
- name: Log in to GitHub registry
if: steps.check_tag.outputs.tag_exists == 'false'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup buildx
if: steps.check_tag.outputs.tag_exists == 'false'
uses: docker/setup-buildx-action@v3
- name: Docker meta
if: steps.check_tag.outputs.tag_exists == 'false'
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- name: Build the image
if: steps.check_tag.outputs.tag_exists == 'false'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
labels: ${{ steps.meta.outputs.labels }}
build-args: |
AWS_CLI_VERSION=${{ env.AWS_CLI_VERSION }}
ALPINE_VERSION=${{ env.ALPINE_VERSION }}
tags: |
${{ env.IMAGE_NAME }}
${{ env.IMAGE_NAME_LATEST }}
- name: Push tag
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
git config --local user.email "[email protected]"
git config --local user.name "Spacelift CI/CD"
git tag -a ${{ env.AWS_CLI_VERSION }} -m "AWS CLI v${{ env.AWS_CLI_VERSION }}"
git push origin ${{ env.AWS_CLI_VERSION }}
- name: Create release
if: steps.check_tag.outputs.tag_exists == 'false'
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.AWS_CLI_VERSION }}
tag: ${{ env.AWS_CLI_VERSION }}
makeLatest: true
skipIfReleaseExists: true
body: |
Release of AWS CLI [v${{ env.AWS_CLI_VERSION }}](https://github.com/aws/aws-cli/releases/tag/${{ env.AWS_CLI_VERSION }}) on Alpine Linux v${{ env.ALPINE_VERSION }}.
The image is available on GitHub Container Registry:
- [`${{ env.IMAGE_NAME }}`](https://github.com/${{ github.repository }}/pkgs/container/aws-cli-alpine)
To use it in your Dockerfile, add the following lines:
```dockerfile
COPY --from=${{ env.IMAGE_NAME }} /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=${{ env.IMAGE_NAME }} /aws-cli-bin/ /usr/local/bin/
```