-
Notifications
You must be signed in to change notification settings - Fork 44
72 lines (67 loc) · 2.55 KB
/
autobuild-apps-tag.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
71
72
name: Auto tag image
on:
# Allows you to run this workflow manually from the Actions tab
issue_comment:
types:
- created
workflow_dispatch:
inputs:
fromImage:
description: 'from remote image name'
required: true
# schedule:
# - cron: '0 22 * * *'
jobs:
build-images:
if: (startswith(github.event.comment.body, '/imagesync') && github.event.comment.user.login=='sealos-ci-robot' ) || (github.event.inputs.fromImage != '' && github.event.sender.login=='cuisongliu')
name: Auto tag app image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: check podman
run: |
sudo podman version
- name: Set fromImage environment variable
id: set_fromImage
run: |
if [[ ${{ github.event_name }} == "issue_comment" ]]; then
FROM_IMAGE=$(echo ${{ github.event.comment.body }} | cut -d' ' -f2)
else
FROM_IMAGE=${{ github.event.inputs.fromImage }}
fi
echo "FROM_IMAGE=$FROM_IMAGE" >> $GITHUB_ENV
- name: Auto build image
env:
registry: ${{ vars.D_REGISTRY_NAME }}
repo: ${{ vars.D_REGISTRY_REPOSITORY }}
username: ${{ vars.D_REGISTRY_REPOSITORY }}
password: ${{ secrets.D_REGISTRY_TOKEN }}
run: |
sudo podman run -it --rm -v ${PWD}:/workspace -w /workspace quay.io/skopeo/stable:latest \
sync --src docker --dest docker --all ${{ env.FROM_IMAGE }} ${registry}/${repo} \
--dest-username ${username} --dest-password ${password} --keep-going --retry-times 2
outputs:
fromImage: ${{ env.FROM_IMAGE }}
add-tips:
if: startswith(github.event.comment.body, '/imagesync')
needs:
- build-images
name: Auto add tips
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Set fromImage environment variable
id: set_fromImage
run: |
FROM_IMAGE=$(echo ${{ github.event.comment.body }} | cut -d' ' -f2)
echo "FROM_IMAGE=$FROM_IMAGE" >> $GITHUB_ENV
- name: Success Commit
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
body: |
🤖 says: Hooray! The action sync image has been completed successfully. 🎉
${{ env.FROM_IMAGE }} to ${{ vars.D_REGISTRY_NAME }}/${{ vars.D_REGISTRY_REPOSITORY }}
See: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}