-
Notifications
You must be signed in to change notification settings - Fork 6
70 lines (67 loc) · 2.8 KB
/
publish-atlantis-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Publish Atlantis Image
on:
push:
paths:
- "atlantis/**"
- ".github/workflows/publish-atlantis-image.yml"
branches:
- master
schedule:
- cron: "0 0 * * *" # Run every day at midnight
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/atlantis
jobs:
build-latest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU #emulation support with QEMU to be able to build against more platforms.
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch latest release from upstream
id: fetch_release
run: |
latest_release=$(curl --silent "https://api.github.com/repos/runatlantis/atlantis/releases/latest" | jq -r .tag_name)
echo "Latest upstream release: $latest_release"
echo "::set-output name=upstream_release::$latest_release"
- name: Get the latest release from our repository
id: get_current_release
run: |
latest_tag=$(curl --silent -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/orgs/skyscrapers/packages/container/atlantis/versions" | jq -r '.[0].metadata.container.tags[]' | grep -v latest | sort -rV | head -n 1)
echo "Current release: $latest_tag"
echo "::set-output name=current_release::$latest_tag"
- name: Compare releases
id: compare_releases
run: |
if [ "${{ steps.fetch_release.outputs.upstream_release }}" != "${{ steps.get_current_release.outputs.current_release }}" ]; then
echo "New release found: ${{ steps.fetch_release.outputs.upstream_release }}"
echo "::set-output name=new_release::true"
else
echo "No new release found"
echo "::set-output name=new_release::false"
fi
- name: Build and push the container to GitHub Container Registry using the latest tag
if: steps.compare_releases.outputs.new_release == 'true' || github.event_name == 'push'
uses: docker/[email protected]
with:
context: .
file: atlantis/Dockerfile
build-args: |
ATLANTIS_VERSION=${{ steps.fetch_release.outputs.upstream_release }}
platforms: |
linux/amd64
linux/arm64
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.fetch_release.outputs.upstream_release }}
push: true
provenance: false