blob: ceb6941f16737de52b75a06d4698bd929c6d630a [file] [log] [blame]
Mohammed Naser1de55192023-04-28 17:13:35 -04001name: image
2
3on:
4 pull_request:
Mohammed Naser05d2af52024-01-01 21:11:26 -05005 paths-ignore:
Mohammed Naser93d643d2024-01-02 13:58:24 -05006 - images/**
Mohammed Naser05d2af52024-01-01 21:11:26 -05007 - go.mod
8 - go.sum
Mohammed Naser1de55192023-04-28 17:13:35 -04009 push:
10 branches:
11 - main
Mohammed Naserb427d382024-06-25 13:39:32 -040012 - stable/*
Mohammed Naser1de55192023-04-28 17:13:35 -040013 release:
14 types:
15 - published
16
Mohammed Naser55bbbf62023-04-28 22:24:55 +000017permissions:
18 packages: write
19 contents: read
20
Mohammed Naser1de55192023-04-28 17:13:35 -040021jobs:
22 build:
23 runs-on: ubuntu-latest
24 steps:
25 - name: Checkout project
renovate[bot]e0441322024-05-19 00:14:14 +020026 uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
Mohammed Naser1de55192023-04-28 17:13:35 -040027
28 - name: Install Earthly
29 uses: earthly/actions-setup@v1
30 with:
31 github-token: ${{ secrets.GITHUB_TOKEN }}
32
Mohammed Naser55bbbf62023-04-28 22:24:55 +000033 - name: Login to GitHub Container Registry
renovate[bot]01f19a72024-04-03 11:30:53 -040034 uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
Mohammed Naser5c1338a2023-04-28 21:37:57 +000035 with:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000036 registry: ghcr.io
37 username: ${{ github.actor }}
38 password: ${{ secrets.GITHUB_TOKEN }}
Mohammed Naser5c1338a2023-04-28 21:37:57 +000039
Mohammed Naser1de55192023-04-28 17:13:35 -040040 - name: Build image
41 run: earthly +image --tag ${{ github.sha }}
42 env:
Mohammed Naser804d9122023-04-28 22:01:40 +000043 EARTHLY_CI: true
Mohammed Naserb7b010a2024-06-25 15:04:38 -040044 EARTHLY_PUSH: "${{ github.event_name == 'push' || github.event_name == 'release' }}"
Mohammed Naserccc70cc2023-04-28 22:20:34 +000045 EARTHLY_REMOTE_CACHE: ghcr.io/vexxhost/atmosphere:cache
Mohammed Naser1de55192023-04-28 17:13:35 -040046
47 publish:
48 runs-on: ubuntu-latest
49 if: github.event_name == 'release'
50 needs:
51 - build
52 steps:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000053 - name: Login to GitHub Container Registry
renovate[bot]01f19a72024-04-03 11:30:53 -040054 uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
Mohammed Naser1de55192023-04-28 17:13:35 -040055 with:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000056 registry: ghcr.io
57 username: ${{ github.actor }}
58 password: ${{ secrets.GITHUB_TOKEN }}
Mohammed Naser1de55192023-04-28 17:13:35 -040059
60 - name: Promote image
renovate[bot]6f8e8b42024-04-19 22:53:37 +000061 uses: akhilerm/tag-push-action@f35ff2cb99d407368b5c727adbcc14a2ed81d509 # v2.2.0
Mohammed Naser1de55192023-04-28 17:13:35 -040062 with:
Mohammed Naserccc70cc2023-04-28 22:20:34 +000063 src: ghcr.io/vexxhost/atmosphere:${{ github.sha }}
64 dst: ghcr.io/vexxhost/atmosphere:${{ github.event.release.tag_name }}